
> ################
> #PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
> #
> #Observational Data
> #Part I: Income
> #
> #Verena Fetscher
> #July 2022
> ####################
> 
> rm(list=ls())

> ##########################
> #Load Data
> ##########################
> 
> 
> #European Social Survey
> 
> #ESS1-7 Cumulative Data
> #http://www.europeansocialsurvey.org/downloadwizard/
> #(accessed 22-03-2017)
> #Converted to stata12 file and saved as R file
> load("ESSR1-R7.Rda")

> ##########################
> 
> 
> #OECD 
> 
> #Calculation purchasing power parity 
> #website https://data.oecd.org/conversion/purchasing-power-parities-ppp.htm
> #(accessed 22-03-2017)
> PPP<-read.csv("DP_LIVE_22032017110129581.csv", header = TRUE, sep = ",", quote = "\"",
+               dec = ".")

> names(PPP) <- c("LOCATION","INDICATOR","SUBJECT","MEASURE","FREQUENCY","TIME","Value","Flag.Codes")

> ##########################
> 
> 
> ##########################
> #Reduces data frame
> ##########################
> ESS<-data

> ESS%>%
+   select(cntry,essround,
+          hinctnt,hinctnta,dweight,pspwght,pweight,
+          iscoco,isco08,marital,maritala,maritalb,chldhhe,
+          gincdif,pplstrd,gndr,uempla,eduyrs,agea,
+          hincfel,health,lrscale,stflife,rtrd,hhmmb) -> data

> ##########################
> #Recode income data
> ##########################
> 
> #ESS asks respondents to place their total net household income into a number of income bands 
> #(12 bands in 2002-06, 10 bands in 2008-2014) 
> #Tables givw yearly, monthly, or weekly figures
> 
> #Four steps
> #1) Follwoing American politics literature, transform income bands into midpoints (e.g. Hout 2004)
> #2) Impute top-coded income category by assuming upper tail of income distribution follows 
> #   Pareto distribution (e.g. Kopczuk/Saez/Song 2010)
> #3) Purchasing power varies across countries, convert country's currency into 2005 PPP-adjusted constant US dollars
> #4) Distance between respondent income and mean income of country year 
> 
> data$income<-NA

> data$income.PPP<-NA

> data$income_dist<-NA

> ##########################
> #Austria 2002
> ##########################
> 
> #1) Midpoints
> table(data$hinctnt[data$cntry=="AT"])

         J          R          C          M          F          S          K          P 
        44         60        155        480        690        802        768        542 
         D          H          U          N    Refusal Don't know  No answer 
       485        121         55         36          0          0          0 

> #Austria R1 2002
> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="N"]<-120000 

> table(data$hinctnt[data$cntry=="AT"&data$essround==1])

         J          R          C          M          F          S          K          P 
        14         21         72        184        272        274        266        167 
         D          H          U          N    Refusal Don't know  No answer 
       140         34         21          7          0          0          0 

> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> table(data$income[data$cntry=="AT"&data$essround==1])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      14       21       72      184      272      274      266      167      140       34 
104999.5   120000 
      21        7 

> ##########################
> 
> 
> #2) Interpolation top income
> #Source http://piketty.pse.ens.fr/files/oldfichiers051211/enseig/ecoineg/CourseNotes2009-2010(D).htm
> #Methodology M2: Standard log-linear interpolation methodology
> 
> #Waves years 2002-06 (12 income bands)  
> interpolation<-function(income,low_limit){
+   counts<-income
+   
+   #calculate percentages in each category
+   nB<-(counts[[12]]/sum(counts))      #observations in highest category
+   nB_1<-(counts[[11]]/sum(counts))    #observations in second highest category
+   
+   #Absolut income
+   lB<-as.numeric(names(counts)[12])   #Lower limit highest bracket
+   lB_1<-low_limit                     #lower limit second highest bracket
+   
+   #Equation for interpolation
+   country_alpha<-(log((nB_1+nB)/nB))/(log(lB/lB_1))
+   country_beta<-country_alpha/(country_alpha-1)
+   
+   top_country<-(lB*country_alpha)/(country_alpha-1)
+   
+   return(top_country)
+ }

> #Waves years 2008-2014 (10 income bands)
> interpolation_change<-function(income,low_limit){
+   counts<-income
+   
+   #calculate percentages in each category
+   nB<-(counts[[10]]/sum(counts))      #observations in highest category
+   nB_1<-(counts[[9]]/sum(counts))    #observations in second highest category
+   
+   #Absolut income
+   lB<-as.numeric(names(counts)[10])   #Lower limit highest bracket
+   lB_1<-low_limit                     #lower limit second highest bracket
+   
+   #Equation for interpolation
+   country_alpha<-(log((nB_1+nB)/nB))/(log(lB/lB_1))
+   country_beta<-country_alpha/(country_alpha-1)
+   
+   top_country<-(lB*country_alpha)/(country_alpha-1)
+   
+   return(top_country)
+ }

> select<-data$cntry=="AT"&data$essround==1

> top_AT<-interpolation(table(data$income[select]),90000)

> ##########################
> #Application
> ##########################
> 
> data$income[data$cntry=="AT"&data$essround==1&data$hinctnt=="N"]<-top_AT

> table(data$income[select])

          899.5          2699.5          4799.5          8999.5         14999.5 
             14              21              72             184             272 
        20999.5         26999.5         32999.5         47999.5         74999.5 
            274             266             167             140              34 
       104999.5 151423.14085715 
             21               7 

> ##########################
> 
> 
> #3) Adjust to PPP
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="AUT"&PPP$TIME==2005]

> table(data$income.PPP[select])

1019.91180795951 3060.86928914585 5441.98635052991  10204.220473298 17007.4120772525 
              14               21               72              184              272 
 23810.603681207 30613.7952851614 37416.9868891159 54424.9658990021 85039.3281167972 
             274              266              167              140               34 
 119055.28613657 171693.440087296 
              21                7 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 28602.47

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-27582.5555330851 -25541.5980518987 -23160.4809905147 -18398.2468677465 -11595.0552637921 
               14                21                72               184               272 
 -4791.8636598376  2011.32794411687  8814.51954807134  25822.4985579575  56436.8607757526 
              274               266               167               140                34 
  90452.818795525  143090.972746251 
               21                 7 

> ##########################
> #Austria 2004
> ##########################
> 
> #Austria R2 2004
> country<-"AT"

> round<-2

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         8         13         40        144        215        221        202        186 
         D          H          U          N    Refusal Don't know  No answer 
       184         37         13         14          0          0          0 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
       8       13       40      144      215      221      202      186      184       37 
104999.5   120000 
      13       14 

> ###########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top_AT<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top_AT    #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
               8               13               40              144              215 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             221              202              186              184               37 
        104999.5 213530.441325598 
              13               14 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="AUT"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1019.91180795951 3060.86928914585 5441.98635052991  10204.220473298 17007.4120772525 
               8               13               40              144              215 
 23810.603681207 30613.7952851614 37416.9868891159 54424.9658990021 85039.3281167972 
             221              202              186              184               37 
 119055.28613657 242114.750935833 
              13               14 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 32807.59

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31787.6802947404 -29746.7228135541   -27365.60575217 -22603.3716294019 -15800.1800254474 
                8                13                40               144               215 
-8996.98842149297 -2193.79681753851  4609.39478641596  21617.3737963021  52231.7360140972 
              221               202               186               184                37 
 86247.6940338696  209307.158833133 
               13                14 

> ##########################
> 
> 
> 
> ##########################
> #Austria 2006
> ##########################
> 
> #Austria R3 2006
> country<-"AT"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        22         26         43        152        203        307        300        189 
         D          H          U          N    Refusal Don't know  No answer 
       161         50         21         15          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      22       26       43      152      203      307      300      189      161       50 
104999.5   120000 
      21       15 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top_AT<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top_AT    #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
              22               26               43              152              203 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             307              300              189              161               50 
        104999.5 178731.935846082 
              21               15 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="AUT"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1019.91180795951 3060.86928914585 5441.98635052991  10204.220473298 17007.4120772525 
              22               26               43              152              203 
 23810.603681207 30613.7952851614 37416.9868891159 54424.9658990021 85039.3281167972 
             307              300              189              161               50 
 119055.28613657 202657.934217766 
              21               15 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 31873.6

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-30853.6896785581 -28812.7321973718 -26431.6151359877 -21669.3810132196 -14866.1894092651 
               22                26                43               152               203 
-8062.99780531066  -1259.8062013562  5543.38540259827  22551.3644124844  53165.7266302795 
              307               300               189               161                50 
 87181.6846500519  170784.332731248 
               21                15 

> ##########################
> 
> 
> 
> ##########################
> #Austria 2008
> ##########################
> 
> #Austria R4 2008
> table(data$cntry[data$essround==4])

  BE   BG   CH   CY   CZ   DE   DK   EE   ES   FI   FR   GB   GR   HR   HU   IE   IL   NL   NO 
1760 2230 1819 1215 2018 2751 1610 1661 2576 2195 2073 2352 2072 1484 1544 1764 2490 1778 1549 
  PL   PT   RU   SE   SI   SK   TR   UA 
1619 2367 2512 1830 1286 1810 2416 1845 

> #Austria R5 2010
> table(data$cntry[data$essround==5])

  BE   BG   CH   CY   CZ   DE   DK   EE   ES   FI   FR   GB   GR   HR   HU   IE   IL   LT   NL 
1704 2434 1506 1083 2386 3031 1576 1793 1885 1878 1728 2422 2715 1649 1561 2576 2294 1677 1829 
  NO   PL   PT   RU   SE   SI   SK   UA 
1548 1751 2150 2595 1497 1403 1856 1931 

> #Austria R6 2012
> table(data$cntry[data$essround==6])

  BE   BG   CH   CY   CZ   DE   DK   EE   ES   FI   FR   GB   HU   IE   IL   IS   IT   LT   NL 
1869 2260 1493 1116 2009 2958 1650 2380 1889 2197 1968 2286 2014 2628 2508  752  960 2109 1845 
  NO   PL   PT   RU   SE   SI   SK   UA 
1624 1898 2151 2484 1847 1257 1847 2178 

> #Austria R7 2014
> table(data$cntry[data$essround==7])

  AT   BE   CH   CZ   DE   DK   EE   ES   FI   FR   GB   HU   IE   IL   LT   NL   NO   PL   PT 
1795 1769 1532 2148 3045 1502 2051 1925 2087 1917 2264 1698 2390 2562 2250 1919 1436 1615 1265 
  SE   SI 
1791 1224 

> country<-"AT"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            126             203             167             177             187 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            158             140              95              50              45 
        Refusal      Don't know       No answer 
              0               0               0 

> #1)Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((12600-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((12600+(18100-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((18100+(22800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((22800+(27100-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((27100+(32800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((32800+(38900-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((38900+(45600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((45600+(54900-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((54900+(70800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-70800

> table(data$income[data$cntry==country&data$essround==round])

 6299.5 15349.5 20449.5 24949.5 29949.5 35849.5 42249.5 50249.5 62849.5   70800 
    126     203     167     177     187     158     140      95      50      45 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top_AT<-interpolation_change(table(data$income[select]),54900)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top_AT    #change

> table(data$income[select])

          6299.5          15349.5          20449.5          24949.5          29949.5 
             126              203              167              177              187 
         35849.5          42249.5          50249.5          62849.5 107336.445428064 
             158              140               95               50               45 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="AUT"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7142.78425151853 17404.2649208165 23186.9777841778 28289.3714871437 33958.6978237724 
             126              203              167              177              187 
40648.5029009943 47905.2406118791  56976.162750485 71262.8651187894 121705.067389088 
             158              140               95               50               45 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 35047.91

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-27905.1245204468 -17643.6438511488 -11860.9309877875 -6758.53728482169 -1089.21094819297 
              126               203               167               177               187 
 5600.59412902893  12857.3318399137  21928.2539785197   36214.956346824  86657.1586171222 
              158               140                95                50                45 

> ##########################
> 
> 
> 
> ##########################
> #Belgium 2002
> ##########################
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Belgium R1 2002
> country<-"BE"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        10          9         24        185        267        280        249        193 
         D          H          U          N    Refusal Don't know  No answer 
       206         61         15         10          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      10        9       24      185      267      280      249      193      206       61 
104999.5   120000 
      15       10 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
              10                9               24              185              267 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             280              249              193              206               61 
        104999.5 174917.870087784 
              15               10 

> ##########################
> 
> 
> #3) Adjust to PPP
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="BEL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

 1008.6477952159 3027.06472838836 5381.88448375623  10091.523994492 16819.5804384002 
              10                9               24              185              267 
23547.6368823084 30275.6933262165 37003.7497701247 53823.8908798952 84100.1448774821 
             280              249              193              206               61 
117740.427097023 196142.883833135 
              15               10 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 31639.05

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

  -30630.40487452 -28611.9879413476 -26257.1681859797  -21547.528675244 -14819.4722313358 
               10                 9                24               185               267 
-8091.41578742757 -1363.35934351938  5364.69710038881  22184.8382101593  52461.0922077462 
              280               249               193               206                61 
 86101.3744272871  164503.831163399 
               15                10 

> ##########################
> #Belgium 2004
> ##########################
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Belgium R2 2004
> country<-"BE"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        11         17         15        153        258        222        191        183 
         D          H          U          N    Refusal Don't know  No answer 
       207         70         27         15          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      11       17       15      153      258      222      191      183      207       70 
104999.5   120000 
      27       15 

> ##########################
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
              11               17               15              153              258 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             222              191              183              207               70 
        104999.5 166529.331539182 
              27               15 

> ##########################
> 
> #3) Adjust to PPP
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="BEL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

 1008.6477952159 3027.06472838836 5381.88448375623  10091.523994492 16819.5804384002 
              11               17               15              153              258 
23547.6368823084 30275.6933262165 37003.7497701247 53823.8908798952 84100.1448774821 
             222              191              183              207               70 
117740.427097023 186736.457026986 
              27               15 

> ##########################
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 34198.14

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

  -33189.49053886 -31171.0736056876 -28816.2538503197  -24106.614339584 -17378.5578956758 
               11                17                15               153               258 
-10650.5014517676 -3922.44500785938  2805.61143604881  19625.7525458193  49902.0065434062 
              222               191               183               207                70 
 83542.2887629471  152538.318692911 
               27                15 

> ##########################
> 
> 
> ##########################
> #Belgium 2006
> ##########################
> 
> #Belgium R3 2006
> country<-"BE"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        11         11         25        115        256        240        210        239 
         D          H          U          N    Refusal Don't know  No answer 
       313        100         22         17          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      11       11       25      115      256      240      210      239      313      100 
104999.5   120000 
      22       17 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
              11               11               25              115              256 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             240              210              239              313              100 
        104999.5 183615.251529992 
              22               17 

> ##########################
> 
> 
> #3) Adjust to PPP
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="BEL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

 1008.6477952159 3027.06472838836 5381.88448375623  10091.523994492 16819.5804384002 
              11               11               25              115              256 
23547.6368823084 30275.6933262165 37003.7497701247 53823.8908798952 84100.1448774821 
             240              210              239              313              100 
117740.427097023 205895.629376031 
              22               17 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 37104.5

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-36095.8485969921 -34077.4316638197 -31722.6119084518 -27012.9723977161 -20284.9159538079 
               11                11                25               115               256 
-13556.8595098997 -6828.80306599148 -100.746622083287  16719.3944876872  46995.6484852741 
              240               210               239               313               100 
  80635.930704815  168791.132983823 
               22                17 

> ##########################
> 
> 
> 
> ##########################
> #Belgium 2008
> ##########################
> 
> 
> #Belgium R4 2008
> country<-"BE"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
              9              38              76             118             111 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            146             168             217             283             401 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((5000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((5000+(10000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((10000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((12000+(14000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((14000+(16000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((16000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((18000+(21000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((21000+(26000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((26000+(35000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-35000

> table(data$income[data$cntry==country&data$essround==round])

 2499.5  7499.5 10999.5 12999.5 14999.5 16999.5 19499.5 23499.5 30499.5   35000 
      9      38      76     118     111     146     168     217     283     401 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),26000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

          2499.5           7499.5          10999.5          12999.5          14999.5 
               9               38               76              118              111 
         16999.5          19499.5          23499.5          30499.5 78945.1932596105 
             146              168              217              283              401 

> ##########################
> 
> 
> #3) Adjust to PPP
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="BEL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

2802.79618025809 8409.50988351492 12334.2094757947 14576.8949570974 16819.5804384002 
               9               38               76              118              111 
19062.2659197029 21865.6227713313 26350.9937339368 34200.3929184963 88524.6193709833 
             146              168              217              283              401 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 39707.08

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-36904.2862375974 -31297.5725343406 -27372.8729420608 -25130.1874607581 -22887.5019794553 
                9                38                76               118               111 
-20644.8164981526 -17841.4596465242 -13356.0886839187 -5506.68949935916  48817.5369531279 
              146               168               217               283               401 

> ##########################
> #Belgium 2010
> ##########################
> 
> 
> #Belgium R5 2010
> country<-"BE"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             35             101             141             180             162 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            183             238             164             150             105 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((11040-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((11040+(14160 -1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((14160+(17640 -1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((17640+(21360-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((21360+(25560-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((25560+(30600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((30600+(37440-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((37440+(44880-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((44880+(56760-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-56760

> table(data$income[data$cntry==country&data$essround==round])

 5519.5 12599.5 15899.5 19499.5 23459.5 28079.5 34019.5 41159.5 50819.5   56760 
     35     101     141     180     162     183     238     164     150     105 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),44880)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

          5519.5          12599.5          15899.5          19499.5          23459.5 
              35              101              141              180              162 
         28079.5          34019.5          41159.5          50819.5 77189.4846630496 
             183              238              164              150              105 

> ##########################
> 
> 
> #3) Adjust to PPP
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="BEL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6189.25125702521 14128.3578608369 17828.7889049864 21865.6227713313 26306.1400243107 
              35              101              141              180              162 
  31486.74348612 38147.5193655891 46153.9065338399 56986.0774085321 86555.8682815306 
             183              238              164              150              105 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 35916.08

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-29726.8255597547  -21787.718955943 -18087.2879117935 -14050.4540454486 -9609.93679246921 
               35               101               141               180               162 
 -4429.3333306599  2231.44254880921    10237.82971706  21070.0005917522  50639.7914647507 
              183               238               164               150               105 

> ##########################
> #Belgium 2012
> ##########################
> 
> 
> #Belgium R6 2012
> country<-"BE"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             58             145             168             215             199 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            219             243             201             146             111 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((12120-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((12120+(15330-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((15330+(18880-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((18880+(22720-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((22720+(27300-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((27300+(33430-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((33430+(40250-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((40250+(48000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((48000+(60230-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-60230

> table(data$income[data$cntry==country&data$essround==round])

 6059.5 13724.5 17104.5 20799.5 25009.5 30364.5 36839.5 44124.5 54114.5   60230 
     58     145     168     215     199     219     243     201     146     111 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),48000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

          6059.5          13724.5          17104.5          20799.5          25009.5 
              58              145              168              215              199 
         30364.5          36839.5          44124.5          54114.5 82546.2008627008 
             219              243              201              146              111 

> ##########################
> 
> 
> #3) Adjust to PPP
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="BEL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6794.77633697695 15389.8684440697 19180.0069074713 23323.3683341781 28044.2212723203 
              58              145              168              215              199 
34049.0116485084  41309.705894226 49478.6877598712 60680.9017389783  92562.583105739 
             219              243              201              146              111 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 36960.27

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-30165.4934806842 -21570.4013735914 -17780.2629101898  -13636.901483483 -8916.04854534078 
               58               145               168               215               199 
-2911.25816915272  4349.43607656487  12518.4179422101  23720.6319213172  55602.3132880779 
              219               243               201               146               111 

> ##########################
> #Belgium 2014
> ##########################
> 
> #Belgium R7 2014
> country<-"BE"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             52             122             168             181             192 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            181             256             199             167             101 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((12560-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((12560+(15420-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((15420+(19160-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((19160+(23200-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((23200+(28000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((28000+(33900-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((33900+(40880-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((40880+(49800-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((49800+(62360-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-62360

> table(data$income[data$cntry==country&data$essround==round])

 6279.5 13989.5 17289.5 21179.5 25599.5 30949.5 37389.5 45339.5 56079.5   62360 
     52     122     168     181     192     181     256     199     167     101 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),49800)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

          6279.5          13989.5          17289.5          21179.5          25599.5 
              52              122              168              181              192 
         30949.5          37389.5          45339.5          56079.5 81036.5972689618 
             181              256              199              167              101 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="BEL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7041.47173992025 15687.0242703423 19387.4553144918 23749.4785756256 28705.8134893046 
              52              122              168              181              192 
34704.9971517894 41926.4444015842 50841.1191897626 62884.3402243583 90869.8000746386 
             181              256              199              167              101 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 38393.41

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31351.9373962598 -22706.3848658378 -19005.9538216883 -14643.9305605544  -9687.5956468754 
               52               122               168               181               192 
 -3688.4119843906  3533.03526540419  12447.7100535826  24490.9310881782  52476.3909384586 
              181               256               199               167               101 

> ##########################
> 
> 
> ##########################
> #Switzerland 2002
> ##########################
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Switzerland Round 1
> country<-"CH"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         9          9         22         26         74         93        123        164 
         D          H          U          N    Refusal Don't know  No answer 
       581        319        115         65          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((2760-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((2760+(5400-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((5400+(9000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((9000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((18000+(27600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((27600+(36000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((36000+(45600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((45600+(54000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((54000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((90000+(135600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((135600+(180000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-180000 

> table(data$income[data$cntry==country&data$essround==round])

  1379.5   4079.5   7199.5  13499.5  22799.5  31799.5  40799.5  49799.5  71999.5 112799.5 
       9        9       22       26       74       93      123      164      581      319 
157799.5   180000 
     115       65 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),135600)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

          1379.5           4079.5           7199.5          13499.5          22799.5 
               9                9               22               26               74 
         31799.5          40799.5          49799.5          71999.5         112799.5 
              93              123              164              581              319 
        157799.5 249336.342781051 
             115               65 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> table(PPP$LOCATION)

 ARG  AUS  AUT  BEL  BRA  CAN  CHE  CHL  CHN  COL  CRI  CZE  DEU  DEW  DNK EA19  ESP  EST EU28 
  27   57   57   57   24   57   57   31   37   37   27   27   57   36   57   22   57   24   22 
 FIN  FRA  GBR  GRC  HUN  IDN  IND  IRL  ISL  ISR  ITA  JPN  KOR  LTU  LUX  LVA  MEX  NLD  NOR 
  57   57   57   57   26   37   37   57   57   40   57   57   47   22   57   23   57   57   57 
 NZL  POL  PRT  RUS  SAU  SVK  SVN  SWE  TUR  USA  ZAF 
  57   27   57   22   27   25   27   57   57   57   47 

> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="CHE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

817.942922466482 2418.84606901197 4268.77859390898 8004.21926918178  13518.441218394 
               9                9               22               26               74 
18854.7850402123 24191.1288620306 29527.4726838489 42690.4541110007  66881.879436577 
              93              123              164              581              319 
93563.5985456684 147838.272483826 
             115               65 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 48381.75

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-47563.8088794272 -45962.9057328817 -44112.9732079847 -40377.5325327119 -34863.3105834997 
                9                 9                22                26                74 
-29526.9667616814 -24190.6229398631 -18854.2791180448 -5691.29769089299  18500.1276346833 
               93               123               164               581               319 
 45181.8467437747  99456.5206819318 
              115                65 

> ##########################
> 
> 
> 
> ##########################
> #Switzerland 2004
> ##########################
> 
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Switzerland R2 2004
> country<-"CH"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         7         11         15         40         89        104        135        215 
         D          H          U          N    Refusal Don't know  No answer 
       568        343         89         62          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((2700-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((2700+(5400-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((5400+(9000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((9000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((18000+(27000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((27000+(36000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((36000+(45000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((45000+(54000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((54000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((90000+(135000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((135000+(180000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-180000 

> table(data$income[data$cntry==country&data$essround==round])

  1349.5   4049.5   7199.5  13499.5  22499.5  31499.5  40499.5  49499.5  71999.5 112499.5 
       7       11       15       40       89      104      135      215      568      343 
157499.5   180000 
      89       62 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),135000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    

> table(data$income[select])

          1349.5           4049.5           7199.5          13499.5          22499.5 
               7               11               15               40               89 
         31499.5          40499.5          49499.5          71999.5         112499.5 
             104              135              215              568              343 
        157499.5 265951.735522805 
              89               62 

> ##########################
> 
> 
> #3) Adjust to PPP
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="CHE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

800.155109727088 2401.05825627258 4268.77859390898 8004.21926918178 13340.5630910001 
               7               11               15               40               89 
18676.9069128184 24013.2507346367  29349.594556455 42690.4541110007  66704.001309183 
             104              135              215              568              343 
93385.7204182745 157689.988973219 
              89               62 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 46670.82

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-45870.6625939517 -44269.7594474062 -42402.0391097698  -38666.598434497 -33330.2546126787 
                7                11                15                40                89 
-27993.9107908605 -22657.5669690422 -17321.2231472239 -3980.36359267813  20033.1836055042 
              104               135               215               568               343 
 46714.9027145957   111019.17126954 
               89                62 

> ##########################
> 
> 
> 
> ##########################
> #Switzerland 2006
> ##########################
> 
> #Switzerland R3 2006
> country<-"CH"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         3         13         11         24         70         83        124        177 
         D          H          U          N    Refusal Don't know  No answer 
       456        316         91         71          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((2700-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((2700+(5400-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((5400+(9000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((9000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((18000+(27000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((27000+(36000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((36000+(45000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((45000+(54000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((54000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((90000+(135000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((135000+(180000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-180000 

> table(data$income[data$cntry==country&data$essround==round])

  1349.5   4049.5   7199.5  13499.5  22499.5  31499.5  40499.5  49499.5  71999.5 112499.5 
       3       13       11       24       70       83      124      177      456      316 
157499.5   180000 
      91       71 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),135000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

          1349.5           4049.5           7199.5          13499.5          22499.5 
               3               13               11               24               70 
         31499.5          40499.5          49499.5          71999.5         112499.5 
              83              124              177              456              316 
        157499.5 276387.674385478 
              91               71 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="CHE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

800.155109727088 2401.05825627258 4268.77859390898 8004.21926918178 13340.5630910001 
               3               13               11               24               70 
18676.9069128184 24013.2507346367  29349.594556455 42690.4541110007  66704.001309183 
              83              124              177              456              316 
93385.7204182745 163877.739848186 
              91               71 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 49762.3

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-48962.1434607926 -47361.2403142471 -45493.5199766107 -41758.0793013379 -36421.7354795196 
                3                13                11                24                70 
-31085.3916577013  -25749.047835883 -20412.7040140647 -7071.84445951896  16941.7027386634 
               83               124               177               456               316 
 43623.4218477548  114115.441277666 
               91                71 

> ##########################
> 
> 
> ##########################
> #Switzerland 2008
> ##########################
> 
> #Switzerland R4 2008
> country<-"CH"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             92             172             158             164             163 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            134             176             148              98              76 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((31500-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((31500+(45000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((45000+(55500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((55500+(65000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((65000+(75500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((75500+(87500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((87500+(102000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((102000+(122000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((122000+(156500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-156500

> table(data$income[data$cntry==country&data$essround==round])

 15749.5  38249.5  50249.5  60249.5  70249.5  81499.5  94749.5 111999.5 139249.5   156500 
      92      172      158      164      163      134      176      148       98       76 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),122000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

         15749.5          38249.5          50249.5          60249.5          70249.5 
              92              172              158              164              163 
         81499.5          94749.5         111999.5         139249.5 223779.211317134 
             134              176              148               98               76 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="CHE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

9338.30522463636 22679.1647791821 29794.2898749398 35723.5607880713 41652.8317012027 
              92              172              158              164              163 
48323.2614784756 56179.5454383747 66407.5377635264 82564.8010018096 132684.756862618 
             134              176              148               98               76 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 48140.58

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-38802.2729096677  -25461.413355122 -18346.2882593643 -12417.0173462328  -6487.7464331014 
               92               172               158               164               163 
  182.68334417147  8038.96730407063  18266.9596292224  34424.2228675055  84544.1787283136 
              134               176               148                98                76 

> ##########################
> 
> 
> 
> ##########################
> #Switzerland 2010
> ##########################
> 
> #SwitzerlandR5 2010
> country<-"CH"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             49             115             136             149             127 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            128             153             160             112             104 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((32500-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((32500+(45500 -1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((45500+(56500 -1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((56500+(68000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((68000+(79500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((79500+(91500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((91500+(106000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((106000+(127500-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((127500+(165500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-165500

> table(data$income[data$cntry==country&data$essround==round])

 16249.5  38999.5  50999.5  62249.5  73749.5  85499.5  98749.5 116749.5 146499.5   165500 
      49      115      136      149      127      128      153      160      112      104 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),127500)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

         16249.5          38999.5          50999.5          62249.5          73749.5 
              49              115              136              149              127 
         85499.5          98749.5         116749.5         146499.5 257347.814826635 
             128              153              160              112              104 

> ##########################
> 
> 
> #3) Adjust to PPP
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="CHE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

9634.76877029293  23123.860097667 30238.9851934247 36909.4149706975 43728.0765207987 
              49              115              136              149              127 
50694.9698437281 58551.2538036273 69223.9414472639 86863.5224138299  152588.49130095 
             128              153              160              112              104 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 57111

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-47476.2323044997 -33987.1409771257  -26872.015881368 -20201.5861040951  -13382.924553994 
               49               115               136               149               127 
-6416.03123106452  1440.25272883463  12112.9403724712  29752.5213390372  95477.4902261576 
              128               153               160               112               104 

> ##########################
> #Switzerland 2012
> ##########################
> 
> #Switzerland R6 2012
> country<-"CH"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             65             125             123             146             142 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            163             167             116             104              86 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((34500-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((34500+(49500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((49500+(61500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((61500+(75000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((75000+(88000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((88000+(105000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((105000+(122000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((122000+(145000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((145000+(184500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-184500

> table(data$income[data$cntry==country&data$essround==round])

 17249.5  41999.5  55499.5  68249.5  81499.5  96499.5 113499.5 133499.5 164749.5   184500 
      65      125      123      146      142      163      167      116      104       86 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),145000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

         17249.5          41999.5          55499.5          68249.5          81499.5 
              65              125              123              146              142 
         96499.5         113499.5         133499.5         164749.5 265058.332533816 
             163              167              116              104               86 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="CHE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

10227.6958616061 24902.6413716064 32907.1571043338 40466.9775185764 48323.2614784756 
              65              125              123              146              142 
57217.1678481727 67296.9284004962  79155.470226759 97684.4418302948 157160.266137588 
             163              167              116              104               86 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 59836.12

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-49608.4216489567 -34933.4761389564  -26928.960406229 -19369.1399919864 -11512.8560320872 
               65               125               123               146               142 
-2618.94966239008  7460.81088993336  19319.3527161962   37848.324319732  97324.1486270247 
              163               167               116               104                86 

> ##########################
> 
> 
> ##########################
> #Switzerland 2014
> ##########################
> 
> #Switzerland R7 2014
> country<-"CH"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             92             135             130             151             149 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            173             168             125              88              87 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((35000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((35000+(49000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((49000+(62000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((62000+(75000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((75000+(88000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((88000+(103000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((103000+(122000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((122000+(146000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((146000+(190000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-190000

> table(data$income[data$cntry==country&data$essround==round])

 17499.5  41999.5  55499.5  68499.5  81499.5  95499.5 112499.5 133999.5 167999.5   190000 
      92      135      130      151      149      173      168      125       88       87 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),146000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

         17499.5          41999.5          55499.5          68499.5          81499.5 
              92              135              130              151              149 
         95499.5         112499.5         133999.5         167999.5 304934.251271288 
             173              168              125               88               87 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="CHE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

10375.9276344344 24902.6413716064 32907.1571043338 40615.2092914047 48323.2614784756 
              92              135              130              151              149 
56624.2407568596  66704.001309183 79451.9337724156 99611.4548770625 180803.778648036 
             173              168              125               88               87 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 59597.02

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-49221.0902996066 -34694.3765624346 -26689.8608297072 -18981.8086426363 -11273.7564555654 
               92               135               130               151               149 
-2972.77717718142  7106.98337514202  19854.9158383746  40014.4369430215  121206.760713995 
              173               168               125                88                87 

> ##########################
> 
> 
> 
> ##########################
> #Germany 2002
> ##########################
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Belgium R1 2002
> country<-"DE"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        13         24         50        212        382        430        396        277 
         D          H          U          N    Refusal Don't know  No answer 
       373        128         31         20          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      13       24       50      212      382      430      396      277      373      128 
104999.5   120000 
      31       20 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

          899.5          2699.5          4799.5          8999.5         14999.5 
             13              24              50             212             382 
        20999.5         26999.5         32999.5         47999.5         74999.5 
            430             396             277             373             128 
       104999.5 173240.66591888 
             31              20 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DEU"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1030.68449137812 3093.19931570341  5499.4666107496  10312.001200842 17187.0506152596 
              13               24               50              212              382 
24062.1000296773  30937.149444095 37812.1988585126 54999.8223945568 85937.5447594363 
             430              396              277              373              128 
120312.791831525 198506.356463154 
              31               20 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 34846.22

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-33815.5325621145 -31753.0177377892  -29346.750442743 -24534.2158526506  -17659.166438233 
               13                24                50               212               382 
-10784.1170238153 -3909.06760939762  2965.98180502005  20153.6053410642  51091.3277059437 
              430               396               277               373               128 
  85466.574778032  163660.139409661 
               31                20 

> ##########################
> #Germany 2004
> ##########################
> 
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Germany R2 2004
> country<-"DE"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        27         21         47        223        341        382        327        284 
         D          H          U          N    Refusal Don't know  No answer 
       365        103         30         27          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      27       21       47      223      341      382      327      284      365      103 
104999.5   120000 
      30       27 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
              27               21               47              223              341 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             382              327              284              365              103 
        104999.5 195123.873745527 
              30               27 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DEU"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1030.68449137812 3093.19931570341  5499.4666107496  10312.001200842 17187.0506152596 
              27               21               47              223              341 
24062.1000296773  30937.149444095 37812.1988585126 54999.8223945568 85937.5447594363 
             382              327              284              365              103 
120312.791831525 223581.045655515 
              30               27 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 35429.96

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-34399.2787389603  -32336.763914635 -29930.4966195888 -25117.9620294964 -18242.9126150788 
               27                21                47               223               341 
-11367.8632006611 -4492.81378624343  2382.23562817424  19569.8591642184  50507.5815290979 
              382               327               284               365               103 
 84882.8286011862  188151.082425177 
               30                27 

> ##########################
> 
> 
> 
> ##########################
> #Germany 2006
> ##########################
> 
> #Germany R3 2006
> country<-"DE"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         9         23         49        257        368        390        354        269 
         D          H          U          N    Refusal Don't know  No answer 
       304        111         28         11          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
       9       23       49      257      368      390      354      269      304      111 
104999.5   120000 
      28       11 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
               9               23               49              257              368 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             390              354              269              304              111 
        104999.5 155298.980426545 
              28               11 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DEU"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1030.68449137812 3093.19931570341  5499.4666107496  10312.001200842 17187.0506152596 
               9               23               49              257              368 
24062.1000296773  30937.149444095 37812.1988585126 54999.8223945568 85937.5447594363 
             390              354              269              304              111 
120312.791831525 177948.027406863 
              28               11 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 32865.88

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31835.1985736779 -29772.6837493526 -27366.4164543064 -22553.8818642141 -15678.8324497964 
                9                23                49               257               368 
-8803.78303537874 -1928.73362096108  4946.31579345659  22133.9393295008  53071.6616943803 
              390               354               269               304               111 
 87446.9087664686  145082.144341807 
               28                11 

> ##########################
> 
> 
> 
> ##########################
> #Germany 2008
> ##########################
> 
> #Germany R4 2008
> country<-"DE"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            269             289             322             329             297 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            226             201             159             108              86 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((13200)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((13201+(17500))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((17501+(22100))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((22101+(27000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((27001+(32500))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((32501+(38300))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((38301+(45200))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((45201+(54600))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((54601+(70400))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-70401

> table(data$income[data$cntry==country&data$essround==round])

   6600 15350.5 19800.5 24550.5 29750.5 35400.5 41750.5 49900.5 62500.5   70401 
    269     289     322     329     297     226     201     159     108      86 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),54601)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            6600          15350.5          19800.5          24550.5          29750.5 
             269              289              322              329              297 
         35400.5          41750.5          49900.5          62500.5 102389.211781556 
             226              201              159              108               86 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DEU"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7562.55435585943 17589.2410060031 22688.2359883628 28130.9834414435 34089.3596006055 
             269              289              322              329              297 
40563.3644658488 47839.4584294408 57178.0672173581 71615.6709876352 117321.815083578 
             226              201              159              108               86 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 34777.51

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-27214.9591521635 -17188.2725020198 -12089.2775196601 -6646.53006657941 -688.153907417436 
              269               289               322               329               297 
 5785.85095782587  13061.9449214179  22400.5537093352  36838.1574796123  82544.3015755555 
              226               201               159               108                86 

> ##########################
> 
> 
> 
> ##########################
> #Germany 2010
> ##########################
> 
> #Germany R5 2010
> country<-"DE"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            182             238             286             237             292 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            246             243             259             201             213 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((11340)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((11341+(15420))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((15421+(18950))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((18951+(22630))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((22631+(26500))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((26501+(30700))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((30701+(35710))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((35711+(42380))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((42381+(53770))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-53771

> table(data$income[data$cntry==country&data$essround==round])

   5670 13380.5 17185.5 20790.5 24565.5 28600.5 33205.5 39045.5 48075.5   53771 
    182     238     286     237     292     246     243     259     201     213 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),42381)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            5670          13380.5          17185.5          20790.5          24565.5 
             182              238              286              237              292 
         28600.5          33205.5          39045.5          48075.5 83778.3701942451 
             246              243              259              201              213 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DEU"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6496.92169662469 15331.9331149359 19691.8602852458 23822.6191417418 28148.1710649795 
             182              238              286              237              292 
32771.6417961754  38048.242221741 44739.9569851075 55086.9063538061 95996.7391574685 
             246              243              259              201              213 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 35353.99

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-28857.0656950434 -20022.0542767322 -15662.1271064223 -11531.3682499264 -7205.81632668857 
              182               238               286               237               292 
-2582.34559549269  2694.25483007287   9385.9695934394   19732.918962138  60642.7517658004 
              246               243               259               201               213 

> ##########################
> 
> 
> ##########################
> #Germany 2012
> ##########################
> 
> #Germany R6 2012
> country<-"DE"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            208             271             246             265             306 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            252             302             246             224             233 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((11770)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((11771+(16140))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((16141+(19920))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((19921+(23880))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((23881+(28070))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((28071+(32780))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((32781+(38340))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((38341+(45830))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((45831+(58040))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-58041

> table(data$income[data$cntry==country&data$essround==round])

   5885 13955.5 18030.5 21900.5 25975.5 30425.5 35560.5 42085.5 51935.5   58041 
    208     271     246     265     306     252     302     246     224     233 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),45831)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            5885          13955.5          18030.5          21900.5          25975.5 
             208              271              246              265              306 
         30425.5          35560.5          42085.5          51935.5 89378.1911434139 
             252              302              246              224              233 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DEU"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6743.27763397466  15990.792017151 20660.0964111096  25094.503283409 29763.8076773677 
             208              271              246              265              306 
34862.8026597275 40746.6991168999 48223.3153550791 59509.8548104148 102413.246780373 
             252              302              246              224              233 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 37885.87

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31142.5890245799 -21895.0746414036  -17225.770247445 -12791.3633751456 -8122.05898118692 
              208               271               246               265               306 
-3023.06399882715   2860.8324583453  10337.4486965245  21623.9881518602  64527.3801218185 
              252               302               246               224               233 

> ##########################
> 
> 
> 
> ##########################
> #Germany 2014
> ##########################
> 
> #Belgium R7 2014
> country<-"DE"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            180             227             283             277             237 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            269             297             314             276             345 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((12000)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((12001+(16560))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((16561+(20400))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((20401+(24480))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((24481+(28800))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((28801+(33600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((33601+(39360))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((39361+(46920))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((46921+(59520))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-59521

> table(data$income[data$cntry==country&data$essround==round])

   6000 14280.5 18480.5 22440.5 26640.5 31200.5 36480.5 43140.5 53220.5   59521 
    180     227     283     277     237     269     297     314     276     345 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),46921)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            6000          14280.5          18480.5          22440.5          26640.5 
             180              227              283              277              237 
         31200.5          36480.5          43140.5          53220.5 99981.0503756764 
             269              297              314              276              345 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DEU"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6875.04941441767 16363.1905270986 21175.7251171909 25713.2577307066  30525.792320799 
             180              227              283              277              237 
35750.8298757564 41800.8733604439 49432.1782104476 60982.2612266692 114562.443639693 
             269              297              314              276              345 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 44070.44

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

 -37195.395044293 -27707.2539316121 -22894.7193415197  -18357.186728004 -13544.6521379117 
              180               227               283               277               237 
-8319.61458295424 -2269.57109826669  5361.73375173692  16911.8167679586  70491.9991809822 
              269               297               314               276               345 

> ##########################
> 
> 
> 
> ##########################
> #Denmark 2002
> ##########################
> 
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Denmark R1 2002
> country<-"DK"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         1         15         11         58        155        145        137        158 
         D          H          U          N    Refusal Don't know  No answer 
       420        147         28         16          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((13300-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((13300+(26600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((26600+(44400-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((44400+(88800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((88800+(133200-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((133200+(177600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((177600+(222000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((222000+(266400-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((266400+(444400-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((444400+(666000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((666000+(888000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-888000 

> table(data$income[data$cntry==country&data$essround==round])

  6649.5  19949.5  35499.5  66599.5 110999.5 155399.5 199799.5 244199.5 355399.5 555199.5 
       1       15       11       58      155      145      137      158      420      147 
776999.5   888000 
      28       16 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),666000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

          6649.5          19949.5          35499.5          66599.5         110999.5 
               1               15               11               58              155 
        155399.5         199799.5         244199.5         355399.5         555199.5 
             145              137              158              420              147 
        776999.5 1240887.18361035 
              28               16 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DNK"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

775.955202663232 2327.98230175654 4142.57037626038 7771.74652526805  12952.949773369 
               1               15               11               58              155 
  18134.15302147  23315.356269571  28496.559517672 41472.9063912943 64788.3210077487 
             145              137              158              420              147 
90670.9984948838 144803.799690289 
              28               16 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 34596.43

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-33820.4797341502 -32268.4526350569 -30453.8645605531 -26824.6884115454 -21643.4851634444 
                1                15                11                58               155 
-16462.2819153435 -11281.0786672425 -6099.87541914148   6876.4714544808  30191.8860709352 
              145               137               158               420               147 
 56074.5635580703  110207.364753475 
               28                16 

> ##########################
> 
> 
> ##########################
> #Denmark2004
> ##########################
> 
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Denmark R2 2004
> country<-"DK"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         6         17         16         60        128        142        125        167 
         D          H          U          N    Refusal Don't know  No answer 
       398        167         40         25          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((13300-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((13300+(26600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((26600+(44400-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((44400+(88800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((88800+(133200-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((133200+(177600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((177600+(222000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((222000+(266400-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((266400+(444400-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((444400+(666000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((666000+(888000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-888000

> table(data$income[data$cntry==country&data$essround==round])

  6649.5  19949.5  35499.5  66599.5 110999.5 155399.5 199799.5 244199.5 355399.5 555199.5 
       6       17       16       60      128      142      125      167      398      167 
776999.5   888000 
      40       25 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),666000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

         6649.5         19949.5         35499.5         66599.5        110999.5 
              6              17              16              60             128 
       155399.5        199799.5        244199.5        355399.5        555199.5 
            142             125             167             398             167 
       776999.5 1270525.3737372 
             40              25 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DNK"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

775.955202663232 2327.98230175654 4142.57037626038 7771.74652526805  12952.949773369 
               6               17               16               60              128 
  18134.15302147  23315.356269571  28496.559517672 41472.9063912943 64788.3210077487 
             142              125              167              398              167 
90670.9984948838 148262.391738781 
              40               25 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 36516.23

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-35740.2769478896 -34188.2498487963 -32373.6617742924 -28744.4856252848 -23563.2823771838 
                6                17                16                60               128 
-18382.0791290828 -13200.8758809818 -8019.67263288084  4956.67424074144  28272.0888571959 
              142               125               167               398               167 
  54154.766344331  111746.159588228 
               40                25 

> ##########################
> 
> 
> 
> ##########################
> #Denmark 2006
> ##########################
> 
> #Denmark R3 2006
> country<-"DK"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        23         18          8         45        124        114        138        158 
         D          H          U          N    Refusal Don't know  No answer 
       440        203         33         23          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((13300-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((13300+(26600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((26600+(44400-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((44400+(88800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((88800+(133200-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((133200+(177600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((177600+(222000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((222000+(266400-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((266400+(444400-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((444400+(666000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((666000+(888000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-888000 

> table(data$income[data$cntry==country&data$essround==round])

  6649.5  19949.5  35499.5  66599.5 110999.5 155399.5 199799.5 244199.5 355399.5 555199.5 
      23       18        8       45      124      114      138      158      440      203 
776999.5   888000 
      33       23 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),666000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

          6649.5          19949.5          35499.5          66599.5         110999.5 
              23               18                8               45              124 
        155399.5         199799.5         244199.5         355399.5         555199.5 
             114              138              158              440              203 
        776999.5 1312231.34412075 
              33               23 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DNK"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

775.955202663232 2327.98230175654 4142.57037626038 7771.74652526805  12952.949773369 
              23               18                8               45              124 
  18134.15302147  23315.356269571  28496.559517672 41472.9063912943 64788.3210077487 
             114              138              158              440              203 
90670.9984948838 153129.218522935 
              33               23 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 37490.79

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-36714.8342066657 -35162.8071075724 -33348.2190330685 -29719.0428840609 -24537.8396359599 
               23                18                 8                45               124 
-19356.6363878589 -14175.4331397579 -8994.22989165693  3982.11698196535  27297.5315984198 
              114               138               158               440               203 
 53180.2090855549  115638.429113606 
               33                23 

> ##########################
> 
> 
> 
> ##########################
> #Denmark 2008
> ##########################
> 
> #Denmark R4 2008
> country<-"DK"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             86             127             105             130             160 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            161             158             146             134             185 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((110000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((110000+(147999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((148000+(185999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((186000+(225999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((226000+(276999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((277000+(337999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((338000+(392999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((393000+(449999))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((450000+(533999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-534000

> table(data$income[data$cntry==country&data$essround==round])

 54999.5 128999.5 166999.5 205999.5 251499.5 307499.5 365499.5 421499.5 491999.5   534000 
      86      127      105      130      160      161      158      146      134      185 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),450000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

         54999.5         128999.5         166999.5         205999.5         251499.5 
              86              127              105              130              160 
        307499.5         365499.5         421499.5         491999.5 778571.428890148 
             161              158              146              134              185 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DNK"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6418.09882981824 15053.4375766532 19487.8007169198 24038.8576240356 29348.4240156706 
              86              127              105              130              160 
35883.2749592214 42651.5134364704 49186.3643800212 57413.2749428842 90854.4327982941 
             161              158              146              134              185 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 40610.32

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

 -34192.221559132 -25556.8828122971 -21122.5196720304 -16571.4627649147 -11261.8963732797 
               86               127               105               130               160 
 -4727.0454297289  2041.19304752013  8576.04399107092   16802.954553934  50244.1124093438 
              161               158               146               134               185 

> ##########################
> 
> 
> 
> ##########################
> #Denmark 2010
> ##########################
> 
> #Denmark R5 2010
> country<-"DK"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            102             121             104             102             138 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            155             143             113             146             232 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((121000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((121000+(159999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((160000+(198999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((199000+(241999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((242000+(297999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((298000+(363999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((364000+(423999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((424000+(485999))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((486000+(577999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-578000

> table(data$income[data$cntry==country&data$essround==round])

 60499.5 140499.5 179499.5 220499.5 269999.5 330999.5 393999.5 454999.5 531999.5   578000 
     102      121      104      102      138      155      143      113      146      232 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),486000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

         60499.5         140499.5         179499.5         220499.5         269999.5 
             102              121              104              102              138 
        330999.5         393999.5         454999.5         531999.5 896322.083896682 
             155              143              113              146              232 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DNK"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7059.91454748841 16395.4158954181 20946.4728025338 25730.9172433478 31507.2587023793 
             102              121              104              102              138 
38625.5784801757 45977.2857916704 53095.6055694668 62081.0256168491 104595.200279958 
             155              143              113              146              232 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 47010.61

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-39950.6910612128 -30615.1897132831 -26064.1328061673 -21279.6883653534 -15503.3469063219 
              102               121               104               102               138 
-8385.02712852547 -1033.31981703083  6084.99996076557  15070.4200081479  57584.5946712568 
              155               143               113               146               232 

> ##########################
> 
> 
> 
> ##########################
> #Denmark 2012
> ##########################
> 
> #Denmark R6 2012
> country<-"DK"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            116             132             116             125             142 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            158             167             147             117             187 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((132000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((132000+(173999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((174000+(216999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((217000+(263999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((264000+(324999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((325000+(395999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((396000+(461999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((462000+(529999))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((530000+(629999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-630000

> table(data$income[data$cntry==country&data$essround==round])

 65999.5 152999.5 195499.5 240499.5 294499.5 360499.5 428999.5 495999.5 579999.5   630000 
     116      132      116      125      142      158      167      147      117      187 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),530000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

         65999.5         152999.5         195499.5         240499.5         294499.5 
             116              132              116              125              142 
        360499.5         428999.5         495999.5         579999.5 977809.725385129 
             158              167              147              117              187 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DNK"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7701.73026515858 17854.0879810321 22813.5730721198 28064.7925803302 34366.2559901828 
             116              132              116              125              142 
42068.0446022248 50061.5676313896 57880.0500102807 67682.3264256069 114104.300116896 
             158              167              147              117              187 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 47659.1

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

 -39957.373310199 -29805.0155943254 -24845.5305032378 -19594.3109950273 -13292.8475851748 
              116               132               116               125               142 
-5591.05897313277  2402.46405603203  10220.9464349232  20023.2228502493   66445.196541538 
              158               167               147               117               187 

> ##########################
> 
> 
> 
> ##########################
> #Denmark 2014
> ##########################
> 
> #Denmark R7 2014
> country<-"DK"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            118             123              97             136             136 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            150             150             114              95             208 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((132000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((132000+(173999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((174000+(217999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((218000+(263999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((264000+(325999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((326000+(396999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((397000+(462999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((463000+(530999))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((531000+(630999))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-631000

> table(data$income[data$cntry==country&data$essround==round])

 65999.5 152999.5 195999.5 240999.5 294999.5 361499.5 429999.5 496999.5 580999.5   631000 
     118      123       97      136      136      150      150      114       95      208 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),531000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

         65999.5         152999.5         195999.5         240999.5         294999.5 
             118              123               97              136              136 
        361499.5         429999.5         496999.5         580999.5 1165616.70015555 
             150              150              114               95              208 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="DNK"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7701.73026515858 17854.0879810321 22871.9199555443 28123.1394637548 34424.6028736073 
             118              123               97              136              136 
42184.7383690739 50178.2613982387 57996.7437771298  67799.020192456 136020.203443394 
             150              150              114               95              208 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 52018.93

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-44317.1952636461 -34164.8375477725 -29147.0055732603 -23895.7860650498 -17594.3226551973 
              118               123                97               136               136 
-9834.18715973072 -1840.66413056591  5977.81824832521  15780.0946636514  84001.2779145897 
              150               150               114                95               208 

> ##########################
> 
> 
> 
> ##########################
> #Spain 2002
> ##########################
> 
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> # R1 2002
> country<-"ES"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        10         45        145        278        231        152         74         45 
         D          H          U          N    Refusal Don't know  No answer 
        38         13          3          1          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000  

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      10       45      145      278      231      152       74       45       38       13 
104999.5   120000 
       3        1 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

          899.5          2699.5          4799.5          8999.5         14999.5 
             10              45             145             278             231 
        20999.5         26999.5         32999.5         47999.5         74999.5 
            152              74              45              38              13 
       104999.5 151423.14085715 
              3               1 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="ESP"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

   1168.92871809  3508.0856859188 6237.10214838572 11695.1350733196 19492.3249660822 
              10               45              145              278              231 
27289.5148588449 35086.7047516075 42883.8946443702 62376.8693762768 97464.2238937087 
             152               74               45               38               13 
136450.173357522 196779.163903624 
               3                1 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 21010.23

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-19841.3040086385 -17502.1470408097 -14773.1305783427 -9315.09765340889 -1517.90776064625 
               10                45               145               278               231 
  6279.2821321164  14076.4720248791  21873.6619176417  41366.6366495483  76453.9911669802 
              152                74                45                38                13 
 115439.940630793  175768.931176895 
                3                 1 

> ##########################
> 
> 
> 
> ##########################
> #Spain 2004
> ##########################
> 
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Spain R2 2004
> country<-"ES"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         6         17         60        165        190        172        148        116 
         D          H          U          N    Refusal Don't know  No answer 
        98         48          8          7          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
       6       17       60      165      190      172      148      116       98       48 
104999.5   120000 
       8        7 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
               6               17               60              165              190 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             172              148              116               98               48 
        104999.5 192760.603001499 
               8                7 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="ESP"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

   1168.92871809  3508.0856859188 6237.10214838572 11695.1350733196 19492.3249660822 
               6               17               60              165              190 
27289.5148588449 35086.7047516075 42883.8946443702 62376.8693762768 97464.2238937087 
             172              148              116               98               48 
136450.173357522 250498.504241021 
               8                7 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 33402.5

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-32233.5675993518  -29894.410631523 -27165.3941690561 -21707.3612441223 -13910.1713513596 
                6                17                60               165               190 
-6112.98145859696   1684.2084341657  9481.39832692834   28974.373058835  64061.7275762669 
              172               148               116                98                48 
  103047.67704008  217096.007923579 
                8                 7 

> ##########################
> 
> 
> 
> ##########################
> #Spain 2006
> ##########################
> 
> #Germany R3 2006
> country<-"ES"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         4         21         69        185        222        204        148        106 
         D          H          U          N    Refusal Don't know  No answer 
        96         39         25          8          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((3600+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((6000+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((12000+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((18000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((24000+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((30000+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((36000+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((60000+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((90000+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
       4       21       69      185      222      204      148      106       96       39 
104999.5   120000 
      25        8 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
               4               21               69              185              222 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             204              148              106               96               39 
        104999.5 150566.973061445 
              25                8 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="ESP"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

   1168.92871809  3508.0856859188 6237.10214838572 11695.1350733196 19492.3249660822 
               4               21               69              185              222 
27289.5148588449 35086.7047516075 42883.8946443702 62376.8693762768 97464.2238937087 
             204              148              106               96               39 
136450.173357522 195666.546756428 
              25                8 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 32893.57

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31724.6460470048  -29385.489079176 -26656.4726167091 -21198.4396917752 -13401.2497990126 
                4                21                69               185               222 
-5604.05990624992  2193.12998651273  9990.31987927538   29483.294611182  64570.6491286139 
              204               148               106                96                39 
 103556.598592427  162772.971991333 
               25                 8 

> ##########################
> 
> 
> 
> ##########################
> #Spain 2008
> ##########################
> 
> #Spain R4 2008
> country<-"ES"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            131             152             266             286             234 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            129             152              96              81              97 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((8000)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((8001+(11000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((11001+(14000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((14001+(17000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((17001+(20000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((20001+(23000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((23001+(27000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((27001+(33000))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((33001+(41000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-41001

> table(data$income[data$cntry==country&data$essround==round])

   4000  9500.5 12500.5 15500.5 18500.5 21500.5 25000.5 30000.5 37000.5   41001 
    131     152     266     286     234     129     152      96      81      97 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),33001)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            4000           9500.5          12500.5          15500.5          18500.5 
             131              152              266              286              234 
         21500.5          25000.5          30000.5          37000.5 63819.7188944933 
             129              152               96               81               97 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="ESP"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

 5198.1265951751 12346.2004293653 16244.7953757466 20143.3903221279 24041.9852685092 
             131              152              266              286              234 
27940.5802148906 32488.9409856688 38986.5992296376 48083.3207711941 82935.7445205161 
             129              152               96               81               97 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 26164.05

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-20965.9192229803 -13817.8453887901 -9919.25044240878 -6020.65549602746 -2122.06054964614 
              131               152               266               286               234 
 1776.53439673519   6324.8951675134  12822.5534114823  21919.2749530387  56771.6987023607 
              129               152                96                81                97 

> ##########################
> 
> 
> 
> ##########################
> #Spain 2010
> ##########################
> 
> #Spain R5 2010
> country<-"ES"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            118             145             180             221             177 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            106             145             122             113             138 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((8000)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((8001+(11000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((11001+(14000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((14001+(17000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((17001+(20000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((20001+(23000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((23001+(27000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((27001+(33000))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((33001+(41000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-41001

> table(data$income[data$cntry==country&data$essround==round])

   4000  9500.5 12500.5 15500.5 18500.5 21500.5 25000.5 30000.5 37000.5   41001 
    118     145     180     221     177     106     145     122     113     138 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),33001)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            4000           9500.5          12500.5          15500.5          18500.5 
             118              145              180              221              177 
         21500.5          25000.5          30000.5          37000.5 64350.9604160321 
             106              145              122              113              138 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="ESP"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

 5198.1265951751 12346.2004293653 16244.7953757466 20143.3903221279 24041.9852685092 
             118              145              180              221              177 
27940.5802148906 32488.9409856688 38986.5992296376 48083.3207711941 83626.1096909091 
             106              145              122              113              138 

> ##########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 29650.2

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-24452.0735809655 -17303.9997467753  -13405.404800394 -9506.80985401268 -5608.21490763136 
              118               145               180               221               177 
-1709.61996125003  2838.74080952818  9336.39905349705  18433.1205950535  53975.9095147685 
              106               145               122               113               138 

> ##########################
> 
> 
> 
> ##########################
> #Spain 2012
> ##########################
> 
> #Spain R6 2012
> country<-"ES"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            223             311             162             177             101 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            155             117              95             128             108 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((9170)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((9171+(13980))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((13981+(15130))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((15131+(19720))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((19721+(20950))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((20951+(25700))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((25701+(28840))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((28841+(33070))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((33071+(44430))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-44431

> table(data$income[data$cntry==country&data$essround==round])

   4585 11575.5 14555.5 17425.5 20335.5 23325.5 27270.5 30955.5 38750.5   44431 
    223     311     162     177     101     155     117      95     128     108 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),33071)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            4585          11575.5          14555.5          17425.5          20335.5 
             223              311              162              177              101 
         23325.5          27270.5          30955.5          38750.5 71402.7879976568 
             155              117               95              128              108 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="ESP"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

5958.35260971946 15042.7286006123 18915.3329140178 22644.9887460559 26426.6258440458 
             223              311              162              177              101 
30312.2254739392 35438.8778284306 40227.6519542357 50357.5011565832 92790.1828150673 
             155              117               95              128              108 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 28460.37

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

 -22502.020160882 -13417.6441699891 -9545.03985658369 -5815.38402454556 -2033.74692655568 
              223               311               162               177               101 
 1851.85270333771  6978.50505782915  11767.2791836342  21897.1283859817  64329.8100444658 
              155               117                95               128               108 

> ##########################
> 
> 
> 
> ##########################
> #Spain 2014
> ##########################
> 
> #Spain R7 2014
> country<-"ES"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            164             162             222             207             163 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            180             100             111             113              97 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((9000)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((9001+(11400))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((11401+(14400))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((14401+(16800))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((16801+(20400))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((20401+(25200))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((25201+(27600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((27601+(33000))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((33001+(42600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-42601

> table(data$income[data$cntry==country&data$essround==round])

   4500 10200.5 12900.5 15600.5 18600.5 22800.5 26400.5 30300.5 37800.5   42601 
    164     162     222     207     163     180     100     111     113      97 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),33001)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            4500          10200.5          12900.5          15600.5          18600.5 
             164              162              222              207              163 
         22800.5          26400.5          30300.5          37800.5 63638.7967049259 
             180              100              111              113               97 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="ESP"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

5847.89241957199 13255.8725835209 16764.6080352641 20273.3434870073 24171.9384333886 
             164              162              222              207              163 
29629.9713583225 34308.2852939801 39376.4587242758 49122.9460902291 82700.6304092041 
             180              100              111              113               97 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 27434.31

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-21586.4203623905 -14178.4401984416 -10669.7047466984  -7160.9692949552 -3262.37434857388 
              164               162               222               207               163 
 2195.65857635998  6873.97251201756  11942.1459423133  21688.6333082666  55266.3176272417 
              180               100               111               113                97 

> ##########################
> 
> 
> 
> ##########################
> #Finland 2002
> ##########################
> 
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Finland R1 2002
> country<-"FI"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         0          0         83        250        284        272        287        226 
         D          H          U          N    Refusal Don't know  No answer 
       307         60         15          7          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-NA

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-NA

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((499)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((500+999)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((1000+(1499))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((1500+(1999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((2000+(2499))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((2500+(2999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((3000+(4999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((5000+(7499))/2)*12 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((7500+(10000))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-10000*12

> table(data$income[data$cntry==country&data$essround==round])

  2994   8994  14994  20994  26994  32994  47994  74994 105000 120000 
    83    250    284    272    287    226    307     60     15      7 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

            2994             8994            14994            20994            26994 
              83              250              284              272              287 
           32994            47994            74994           105000 160261.052375811 
             226              307               60               15                7 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FIN"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

3056.89874865227  9182.9483451498 15308.9979416473 21435.0475381449 27561.0971346424 
              83              250              284              272              287 
33687.1467311399 49002.2707223838 76569.4939066227 107205.867938707 163627.859206852 
             226              307               60               15                7 

> mean(data$income.PPP[select],na.rm=T)
[1] 28275.95

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 28275.95

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-25219.0520312509 -19093.0024347534 -12966.9528382558  -6840.9032417583 -714.853645260766 
               83               250               284               272               287 
 5411.19595123677  20726.3199424806  48293.5431267195  78929.9171588037  135351.908426948 
              226               307                60                15                 7 

> mean(data$income_dist[select],na.rm=T)
[1] -2.028677e-12

> ##########################
> 
> 
> 
> ##########################
> #Finland 2004
> ##########################
> 
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #Finland R2 2004
> country<-"FI"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         9         18         84        215        270        279        241        271 
         D          H          U          N    Refusal Don't know  No answer 
       340         86         20         14          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-(149/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((150+299)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((300+499)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((500+999)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((1000+(1499))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((1500+(1999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((2000+(2499))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((2500+(2999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((3000+(4999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((5000+(7499))/2)*12 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((7500+(10000))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-10000*12

> table(data$income[data$cntry==country&data$essround==round])

   894   2694   4794   8994  14994  20994  26994  32994  47994  74994 105000 120000 
     9     18     84    215    270    279    241    271    340     86     20     14 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

             894             2694             4794             8994            14994 
               9               18               84              215              270 
           20994            26994            32994            47994            74994 
             279              241              271              340               86 
          105000 177572.769530622 
              20               14 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FIN"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

912.781389878132 2750.59626882739 4894.71362760153  9182.9483451498 15308.9979416473 
               9               18               84              215              270 
21435.0475381449 27561.0971346424 33687.1467311399 49002.2707223838 76569.4939066227 
             279              241              271              340               86 
107205.867938707 181303.265522003 
              20               14 

> summary(data$income.PPP[select])
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's 
   912.8  15309.0  27561.1  30458.3  33687.2 181303.3      175 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 30458.35

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

 -29545.570577047 -27707.7556980977 -25563.6383393236 -21275.4036217753 -15149.3540252778 
                9                18                84               215               270 
-9023.30442878024 -2897.25483228271  3228.79476421482  18543.9187554587  46111.1419396976 
              279               241               271               340                86 
 76747.5159717817  150844.913555078 
               20                14 

> ##########################
> 
> 
> 
> ##########################
> #Finland 2006
> ##########################
> 
> #Finland R3 2006
> country<-"FI"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         0         14         46        182        234        227        247        238 
         D          H          U          N    Refusal Don't know  No answer 
       386        110         24         16          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-(149/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((150+299)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-((300+499)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-((500+999)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-((1000+(1499))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-((1500+(1999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-((2000+(2499))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-((2500+(2999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-((3000+(4999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-((5000+(7499))/2)*12 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-((7500+(10000))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-10000*12

> table(data$income[data$cntry==country&data$essround==round])

  2694   4794   8994  14994  20994  26994  32994  47994  74994 105000 120000 
    14     46    182    234    227    247    238    386    110     24     16 

> ##########################
> 
> 
> #2) Interpolation top income
> #Adapt function to only 11 income bands
> interpolation_11<-function(income,low_limit){
+   counts<-income
+   
+   #calculate percentages in each category
+   nB<-(counts[[11]]/sum(counts))      #observations in highest category
+   nB_1<-(counts[[10]]/sum(counts))    #observations in second highest category
+   
+   #Absolut income
+   lB<-as.numeric(names(counts)[11])   #Lower limit highest bracket
+   lB_1<-low_limit                     #lower limit second highest bracket
+   
+   #Equation for interpolation
+   country_alpha<-(log((nB_1+nB)/nB))/(log(lB/lB_1))
+   country_beta<-country_alpha/(country_alpha-1)
+   
+   top_country<-(lB*country_alpha)/(country_alpha-1)
+   
+   return(top_country)
+ }

> select<-data$cntry==country&data$essround==round 

> top<-interpolation_11(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

            2694             4794             8994            14994            20994 
              14               46              182              234              227 
           26994            32994            47994            74994           105000 
             247              238              386              110               24 
174917.870087784 
              16 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FIN"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

2750.59626882739 4894.71362760153  9182.9483451498 15308.9979416473 21435.0475381449 
              14               46              182              234              227 
27561.0971346424 33687.1467311399 49002.2707223838 76569.4939066227 107205.867938707 
             247              238              386              110               24 
178592.591245246 
              16 

> summary(data$income.PPP[select])
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
   2751   15309   27561   33629   49002  178593     172 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 33628.83

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-30878.2309447714 -28734.1135859973  -24445.878868449 -18319.8292719515  -12193.779675454 
               14                46               182               234               227 
-6067.73007895643  58.3195175411092  15373.4435087849  42940.6666930238   73577.040725108 
              247               238               386               110                24 
 144963.764031647 
               16 

> ##########################
> 
> 
> 
> ##########################
> #Finland 2008
> ##########################
> 
> #Finland R4 2008
> country<-"FI"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            156             154             175             159             207 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            234             245             247             249             189 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((900-1)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((900+(1199))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((1200+(1499))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((1500+(1799))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((1800+(2199))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((2200+(2599))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((2600+(3099))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((3100+(3699))/2) *12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((3700+(4599))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-4600*12

> table(data$income[data$cntry==country&data$essround==round])

 5394 12594 16194 19794 23994 28794 34194 40794 49794 55200 
  156   154   175   159   207   234   245   247   249   189 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),44400)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            5394            12594            16194            19794            23994 
             156              154              175              159              207 
           28794            34194            40794            49794 74498.8630510196 
             234              245              247              249              189 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FIN"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

5507.31858725128 12858.5781030483 16534.2078609468 20209.8376188454 24498.0723363936 
             156              154              175              159              207 
29398.9120135917 34912.3566504394 41651.0112065867  50840.085601333 76063.9549888706 
             234              245              247              249              189 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 33138.09

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

 -27630.773534024  -20279.514018227 -16603.8842603285 -12928.2545024299 -8640.01978488166 
              156               154               175               159               207 
-3739.18010768364  1774.26452916414  8512.91908531143  17701.9934800577  42925.8628675953 
              234               245               247               249               189 

> ##########################
> 
> 
> 
> ##########################
> #Finland 2010
> ##########################
> 
> #Germany R5 2010
> country<-"FI"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            169             141             171             131             185 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            204             228             213             146             133 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((959-1)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((959+(1231))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((1232+(1615))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((1616+(1970))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((1971+(2370))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((2371+(2886))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((2887+(3484))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((3484+(4159))/2) *12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((4160+(5142))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-5143*12

> table(data$income[data$cntry==country&data$essround==round])

 5748 13140 17082 21516 26046 31542 38226 45858 55812 61716 
  169   141   171   131   185   204   228   213   146   133 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),49920)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            5748            13140            17082            21516            26046 
             169              141              171              131              185 
           31542            38226            45858            55812 86475.3548525707 
             204              228              213              146              133 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FIN"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

5868.75551344464 13416.0486163296 17440.8632012285 21968.0138530402 26593.1812983958 
             169              141              171              131              185 
32204.6427287875 39029.0619792858 46821.3970660307 56984.5133466201 88292.0521169286 
             204              228              213              146              133 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 34379.62

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-28510.8674977166 -20963.5743948317 -16938.7598099328 -12411.6091581211 -7786.44171276548 
              169               141               171               131               185 
-2174.98028237374  4649.43896812451  12441.7740548694  22604.8903354588  53912.4291057673 
              204               228               213               146               133 

> ##########################
> 
> 
> 
> ##########################
> #Finland 2012
> ##########################
> 
> 
> #Finland R6 2012
> country<-"FI"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            159             134             181             207             220 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            237             263             268             217             175 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((1010-1)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((1010+(1292))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((1293+(1694))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((1695+(2070))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((2071+(2479))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((2480+(2986))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((2987+(3617))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((3618+(4311))/2) *12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((4312+(5361))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-5362*12

> table(data$income[data$cntry==country&data$essround==round])

 6054 13812 17922 22590 27300 32796 39624 47574 58038 64344 
  159   134   181   207   220   237   263   268   217   175 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),51744)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            6054            13812            17922            22590            27300 
             159              134              181              207              220 
           32796            39624            47574            58038 88170.4301336321 
             237              263              268              217              175 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FIN"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6181.18404286601 14102.1661711373 18298.5101447381 23064.5767308132 27873.5256640638 
             159              134              181              207              220 
33484.9870944555 40456.4315352697 48573.4472506289 59257.2777469206 90022.7379905251 
             237              263              268              217              175 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 37504.88

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31323.6910726469 -23402.7089443756 -19206.3649707748 -14440.2983846997 -9631.34945144917 
              159               134               181               207               220 
-4019.88802105744  2951.55641975676   11068.572135116  21752.4026314077  52517.8628750122 
              237               263               268               217               175 

> ##########################
> 
> 
> 
> ##########################
> #Finland 2014
> ##########################
> 
> #Finland R7 2014
> country<-"FI"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            166             142             187             204             203 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            210             253             249             176             151 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((1074)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((1075+(1366))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((1367+(1808))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((1809+(2215))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((2216+(2627))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((2628+(3157))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((3158+(3824))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((3825+(4555))/2)*12 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((4556+(5673))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-5674*12

> table(data$income[data$cntry==country&data$essround==round])

 6444 14646 19050 24144 29058 34710 41892 50280 61374 68088 
  166   142   187   204   203   210   253   249   176   151 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),54672)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            6444            14646            19050            24144            29058 
             166              142              187              204              203 
           34710            41892            50280            61374 95096.3602386157 
             210              253              249              176              151 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FIN"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6579.37726663835 14953.6870650505 19450.2074688797 24651.2235763061 29668.4581958376 
             166              142              187              204              203 
35439.1969157382 42772.0782827458 51336.2956186493 62663.3613225733 97094.1698780259 
             210              253              249              176              151 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 38454.72

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31875.3427852624 -23501.0329868502 -19004.5125830211 -13803.4964755946 -8786.26185606317 
              166               142               187               204               203 
-3015.52313616249  4317.35823084506  12881.5755667486  24208.6412706725  58639.4498261252 
              210               253               249               176               151 

> ##########################
> 
> 
> 
> ##########################
> #France 2002
> ##########################
> 
> #France R1 2002
> country<-"FR"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         0          0          0          0          0          0          0          0 
         D          H          U          N    Refusal Don't know  No answer 
         0          0          0          0          0          0          0 

> #France R2 2004
> country<-"FR"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        21         39         46        167        274        240        209        148 
         D          H          U          N    Refusal Don't know  No answer 
       234         73         34         21          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600+1)+(6000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000+1)+(12000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000+1)+(18000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000+1)+(24000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000+1)+(30000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000+1)+(36000))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000+1)+(60000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000+1)+(90000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000+1)+(120000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000+1 

> table(data$income[data$cntry==country&data$essround==round])

   899.5     2700   4800.5   9000.5  15000.5  21000.5  27000.5  33000.5  48000.5  75000.5 
      21       39       46      167      274      240      209      148      234       73 
105000.5   120001 
      34       21 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000+1)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5             2700           4800.5           9000.5          15000.5 
              21               39               46              167              274 
         21000.5          27000.5          33000.5          48000.5          75000.5 
             240              209              148              234               73 
        105000.5 171134.453936757 
              34               21 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FRA"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

981.496151487575 2946.12519067977 5238.10147328083 9820.96288100491 16367.9077491822 
              21               39               46              167              274 
22914.8526173594 29461.7974855367  36008.742353714 52376.1045241571 81837.3564309548 
             240              209              148              234               73 
114572.080771841 186734.639161595 
              34               21 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 32891.61

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31910.1096330636 -29945.4805938714 -27653.5043112704 -23070.6429035463  -16523.698035369 
               21                39                46               167               274 
-9976.75316719174 -3429.80829901448  3117.13656916279   19484.498739606  48945.7506464036 
              240               209               148               234                73 
   81680.47498729  153843.033377044 
               34                21 

> ##########################
> 
> 
> 
> ##########################
> #France 2006
> ##########################
> table(data$cntry)

   AT    BE    BG    CH    CY    CZ    DE    DK    EE    ES    FI    FR    GB    GR    HR 
 8713 12577  8324 12335  4409 12947 20490 10836 11391 13543 14275 12981 15667  9759  3133 
   HU    IE    IL    IS    IT    LT    LU    NL    NO    PL    PT    RU    SE    SI    SK 
11518 15490 12353  1331  3696  6036  3187 13505 11703 12430 13718 10028 12839  9607  8791 
   TR    UA 
 4272  9987 

> #France R3 2006
> country<-"FR"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        22         30         62        159        277        268        259        245 
         D          H          U          N    Refusal Don't know  No answer 
       315         73         18         12          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600+1)+(6000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000+1)+(12000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000+1)+(18000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000+1)+(24000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000+1)+(30000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000+1)+(36000))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000+1)+(60000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000+1)+(90000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000+1)+(120000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000+1 

> table(data$income[data$cntry==country&data$essround==round])

   899.5     2700   4800.5   9000.5  15000.5  21000.5  27000.5  33000.5  48000.5  75000.5 
      22       30       62      159      277      268      259      245      315       73 
105000.5   120001 
      18       12 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90001)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top    #change

> table(data$income[select])

           899.5             2700           4800.5           9000.5          15000.5 
              22               30               62              159              277 
         21000.5          27000.5          33000.5          48000.5          75000.5 
             268              259              245              315               73 
        105000.5 174918.554791335 
              18               12 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FRA"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

981.496151487575 2946.12519067977 5238.10147328083 9820.96288100491 16367.9077491822 
              22               30               62              159              277 
22914.8526173594 29461.7974855367  36008.742353714 52376.1045241571 81837.3564309548 
             268              259              245              315               73 
114572.080771841 190863.689106685 
              18               12 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 32154.81

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

 -31173.315401161 -29208.6863619688 -26916.7100793678 -22333.8486716437 -15786.9038034664 
               22                30                62               159               277 
-9239.95893528917 -2693.01406711191  3853.93080106535  20221.2929715085  49682.5448783062 
              268               259               245               315                73 
 82417.2692191925  158708.877554037 
               18                12 

> ##########################
> 
> 
> 
> ##########################
> #France 2008
> ##########################
> 
> #France R4 2008
> country<-"FR"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            155             163             200             131             165 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            211             205             222             209             205 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((11400)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((11401+(14400))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((14401+(18000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((18001+(21000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((21001+(24000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((24001+(28800))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((28801+(33600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((33601+(39600))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((39601+(49200))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-49201

> table(data$income[data$cntry==country&data$essround==round])

   5700 12900.5 16200.5 19500.5 22500.5 26400.5 31200.5 36600.5 44400.5   49201 
    155     163     200     131     165     211     205     222     209     205 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),39601)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            5700          12900.5          16200.5          19500.5          22500.5 
             155              163              200              131              165 
         26400.5          31200.5          36600.5          44400.5 71184.5880470525 
             211              205              222              209              205 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FRA"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

 6219.5976247684 14076.4770453201 17677.2967228176 21278.1164003151 24551.5888344038 
             155              163              200              131              165 
 28807.102998719 34044.6588932608 39936.9092746203 48447.9376032508 77673.5955679938 
             211              205              222              209              205 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 33014.23

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-26794.6370248778  -18937.757604326 -15336.9379268285  -11736.118249331  -8462.6458152424 
              155               163               200               131               165 
-4207.13165092718  1030.42424361463  6922.67462497417  15433.7029536046  44659.3609183476 
              211               205               222               209               205 

> ##########################
> 
> 
> 
> ##########################
> #France 2010
> ##########################
> 
> #France R5 2010
> country<-"FR"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            250             216             181             191             159 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            157             131             125             105              72 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((13200)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((13201+(16800))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((16801+(21000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((21001+(25200))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((25201+(30000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((30001+(34800))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((34801+(39600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((39601+(48000))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((48001+(61200))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-61201

> table(data$income[data$cntry==country&data$essround==round])

   6600 15000.5 18900.5 23100.5 27600.5 32400.5 37200.5 43800.5 54600.5   61201 
    250     216     181     191     159     157     131     125     105      72 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),48001)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            6600          15000.5          18900.5          23100.5          27600.5 
             250              216              181              191              159 
         32400.5          37200.5          43800.5          54600.5 83847.3435711087 
             157              131              125              105               72 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FRA"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7201.63935499499 16367.9077491822 20623.4219134974 25206.2833212215 30116.4919723544 
             250              216              181              191              159 
35354.0478668962 40591.6037614381  47793.243116433 59577.7438791521 91490.6559505277 
             157              131              125              105               72 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 30470.62

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

 -23268.978760964 -14102.7103667769 -9847.19620246163 -5264.33479473754 -354.126143604597 
              250               216               181               191               159 
 4883.42975093722   10120.985645479   17322.625000474  29107.1257631931  61020.0378345686 
              157               131               125               105                72 

> ##########################
> #France 2012
> ##########################
> 
> #France R6 2012
> country<-"FR"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            264             294             180             185             183 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            204             157             124             104              90 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((13200)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((13201+(18000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((18001+(21600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((21601+(25200))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((25201+(30000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((30001+(36000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((36001+(42000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((42001+(49200))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((49201+(63600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-63601

> table(data$income[data$cntry==country&data$essround==round])

   6600 15600.5 19800.5 23400.5 27600.5 33000.5 39000.5 45600.5 56400.5   63601 
    264     294     180     185     183     204     157     124     104      90 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),49201)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            6600          15600.5          19800.5          23400.5          27600.5 
             264              294              180              185              183 
         33000.5          39000.5          45600.5          56400.5 95531.9305568492 
             204              157              124              104               90 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FRA"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7201.63935499499 17022.6022359999  21605.463643724 25533.6305646303 30116.4919723544 
             264              294              180              185              183 
 36008.742353714 42555.6872218912 49757.3265768862 61541.8273396053 104240.380417705 
             204              157              124              104               90 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 31937.71

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-24736.0749860758 -14915.1121050709 -10332.2506973468 -6404.08377644042 -1821.22236871634 
              264               294               180               185               183 
  4071.0280126432  10617.9728808205  17819.6122358155  29604.1129985345  72302.6660766344 
              204               157               124               104                90 

> ##########################
> 
> 
> 
> ##########################
> #France 2014
> ##########################
> 
> #France R7 2014
> country<-"FR"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            229             218             164             200             175 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            168             214             163             144             124 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((13200)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((13201+(17040))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((17041+(20580))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((20581+(24600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((24601+(29400))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((29401+(34560))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((34561+(40800))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((40801+(49200))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((49201+(63600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-63601

> table(data$income[data$cntry==country&data$essround==round])

   6600 15120.5 18810.5 22590.5 27000.5 31980.5 37680.5 45000.5 56400.5   63601 
    229     218     164     200     175     168     214     163     144     124 

> table(data$income[data$cntry==country&data$essround==round])

   6600 15120.5 18810.5 22590.5 27000.5 31980.5 37680.5 45000.5 56400.5   63601 
    229     218     164     200     175     168     214     163     144     124 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),49201)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

            6600          15120.5          18810.5          22590.5          27000.5 
             229              218              164              200              175 
         31980.5          37680.5          45000.5          56400.5 95366.8726820416 
             168              214              163              144              124 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="FRA"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7201.63935499499 16498.8466465457 20525.2177404747 24649.7930074264 29461.7974855367 
             229              218              164              200              175 
34895.7617261238 41115.3593508922 49102.6320900685 61541.8273396053 104060.276283301 
             168              214              163              144              124 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 35090.74

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-27889.0966927684 -18591.8894012176 -14565.5183072886  -10440.943040337 -5628.93856222666 
              229               218               164               200               175 
-194.974321639529  6024.62330312887  14011.8960423051  26451.0912918419  68969.5402355378 
              168               214               163               144               124 

> ##########################
> 
> 
> 
> ##########################
> #GB 2002
> ##########################
> 
> #GB R1 2002
> country<-"GB"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        15         31         61        290        225        201        163        168 
         D          H          U          N    Refusal Don't know  No answer 
       353        165         60         52          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1190-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1190+(2380-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((2380)+(3970-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((3970)+(7950-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((7950)+(11920-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((11920)+(15890-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((15890)+(19870-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((19870)+(23840-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((23840)+(39740-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((39740)+(59600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((59600)+(79470-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-79470 

> table(data$income[data$cntry==country&data$essround==round])

  594.5  1784.5  3174.5  5959.5  9934.5 13904.5 17879.5 21854.5 31789.5 49669.5 69534.5 
     15      31      61     290     225     201     163     168     353     165      60 
  79470 
     52 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),59600)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           594.5           1784.5           3174.5           5959.5           9934.5 
              15               31               61              290              225 
         13904.5          17879.5          21854.5          31789.5          49669.5 
             201              163              168              353              165 
         69534.5 127152.884467876 
              60               52 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="GBR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

840.141375514224 2521.83731640897 4486.17123056334 8421.90500820357 14039.3347267385 
              15               31               61              290              225 
 19649.698495942  25267.128214477  30884.557933012 44924.5992546837 70192.4340640938 
             201              163              168              353              165 
98265.4507581057 179691.167800576 
              60               52 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 34698.64

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-33858.5011392762 -32176.8051983815 -30212.4712842271 -26276.7375065869 -20659.3077880519 
               15                31                61               290               225 
-15048.9440188484 -9431.51430031347  -3814.0845817785  10225.9567398932  35493.7915493033 
              201               163               168               353               165 
 63566.8082433152  144992.525285786 
               60                52 

> ##########################
> 
> 
> 
> ##########################
> #GB 2004
> ##########################
> 
> #GB R2 2004
> country<-"GB"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        13         28         61        236        243        180        130        124 
         D          H          U          N    Refusal Don't know  No answer 
       256        121         51         40          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1190-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1190+(2380-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((2380)+(3970-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((3970)+(7950-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((7950)+(11920-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((11920)+(15890-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((15890)+(19870-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((19870)+(23840-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((23840)+(39740-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((39740)+(59600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((59600)+(79470-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-79470 

> table(data$income[data$cntry==country&data$essround==round])

  594.5  1784.5  3174.5  5959.5  9934.5 13904.5 17879.5 21854.5 31789.5 49669.5 69534.5 
     13      28      61     236     243     180     130     124     256     121      51 
  79470 
     40 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),59600)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           594.5           1784.5           3174.5           5959.5           9934.5 
              13               28               61              236              243 
         13904.5          17879.5          21854.5          31789.5          49669.5 
             180              130              124              256              121 
         69534.5 122268.632534751 
              51               40 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="GBR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

840.141375514224 2521.83731640897 4486.17123056334 8421.90500820357 14039.3347267385 
              13               28               61              236              243 
 19649.698495942  25267.128214477  30884.557933012 44924.5992546837 70192.4340640938 
             180              130              124              256              121 
98265.4507581057 172788.792464237 
              51               40 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 32584.46

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31744.3136800295 -30062.6177391347 -28098.2838249804 -24162.5500473401 -18545.1203288052 
               13                28                61               236               243 
-12934.7565596017  -7317.3268410667 -1699.89712253173    12340.14419914  37607.9790085501 
              180               130               124               256               121 
  65680.995702562  140204.337408693 
               51                40 

> ##########################
> 
> 
> 
> ##########################
> #GB 2006
> ##########################
> 
> #GB R3 2006
> country<-"GB"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        19         23         54        241        235        190        138        179 
         D          H          U          N    Refusal Don't know  No answer 
       409        233         76         61          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1190-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1190+(2380-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((2380)+(3970-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((3970)+(7950-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((7950)+(11920-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((11920)+(15890-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((15890)+(19870-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((19870)+(23840-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((23840)+(39740-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((39740)+(59600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((59600)+(79470-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-79470 

> table(data$income[data$cntry==country&data$essround==round])

  594.5  1784.5  3174.5  5959.5  9934.5 13904.5 17879.5 21854.5 31789.5 49669.5 69534.5 
     19      23      54     241     235     190     138     179     409     233      76 
  79470 
     61 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),59600)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           594.5           1784.5           3174.5           5959.5           9934.5 
              19               23               54              241              235 
         13904.5          17879.5          21854.5          31789.5          49669.5 
             190              138              179              409              233 
         69534.5 123325.334334378 
              76               61 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="GBR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

840.141375514224 2521.83731640897 4486.17123056334 8421.90500820357 14039.3347267385 
              19               23               54              241              235 
 19649.698495942  25267.128214477  30884.557933012 44924.5992546837 70192.4340640938 
             190              138              179              409              233 
98265.4507581057  174282.11273917 
              76               61 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 38332.7

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-37492.5629319476 -35810.8669910528 -33846.5330768985 -29910.7992992582 -24293.3695807233 
               19                23                54               241               235 
-18683.0058115198 -13065.5760929848 -7448.14637444983  6591.89494722187   31859.729756632 
              190               138               179               409               233 
 59932.7464506439  135949.408431708 
               76                61 

> ##########################
> 
> 
> 
> ##########################
> #GB 2008
> ##########################
> 
> #GB R4 2008
> country<-"GB"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            256             236             206             179             155 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            175             215             185             164             229 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((8550-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((8550+(11470-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((11470+(14440-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((14440+(17360-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((17360+(21120-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((21120+(25650-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((25650+(30870-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((30870+(38060-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((38060+(50110-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-50110

> table(data$income[data$cntry==country&data$essround==round])

 4274.5 10009.5 12954.5 15899.5 19239.5 23384.5 28259.5 34464.5 44084.5   50110 
    256     236     206     179     155     175     215     185     164     229 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),38060)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

          4274.5          10009.5          12954.5          15899.5          19239.5 
             256              236              206              179              155 
         23384.5          28259.5          34464.5          44084.5 102115.609807294 
             175              215              185              164              229 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="GBR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6040.68008349126 14145.3239667109 18307.1681229588 22469.0122792067 27189.0664326424 
             256              236              206              179              155 
33046.7384284481 39936.0390266513 48704.8821470311 62299.7686608189 144308.744970519 
             175              215              185              164              229 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 41767.97

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-35727.2904952173 -27622.6466119976 -23460.8024557497 -19298.9582995018 -14578.9041460661 
              256               236               206               179               155 
-8721.23215026045 -1831.93155205718  6936.91156832258  20531.7980821104  102540.774391811 
              175               215               185               164               229 

> ##########################
> 
> 
> 
> ##########################
> #GB 2010
> ##########################
> 
> #GB R5 2010
> country<-"GB"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            312             243             194             161             162 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            176             182             176             146             154 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((9390-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((9390+(12510-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((12510+(15590-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((15590+(18880-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((18880+(22940-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((22940+(27530-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((27530+(33060-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((33060+(41090-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((41090+(53920-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-53920

> table(data$income[data$cntry==country&data$essround==round])

 4694.5 10949.5 14049.5 17234.5 20909.5 25234.5 30294.5 37074.5 47504.5   53920 
    312     243     194     161     162     176     182     176     146     154 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),41090)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

          4694.5          10949.5          14049.5          17234.5          20909.5 
             312              243              194              161              162 
         25234.5          30294.5          37074.5          47504.5 91005.0280662836 
             176              182              176              146              154 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="GBR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6634.21982733646 15473.7224410311 19854.6110265553 24355.6207507147 29549.0935093603 
             312              243              194              161              162 
35661.1396810996  42811.880404568 52393.3076980692 67132.8780035584 128607.383445447 
             176              182              176              146              154 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 37400.98

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-30766.7644220424 -21927.2618083477 -17546.3732228236 -13045.3634986641 -7851.89074001859 
              312               243               194               161               162 
-1739.84456827928  5410.89615518914  14992.3234486903  29731.8937541796   91206.399196068 
              176               182               176               146               154 

> ##########################
> 
> 
> 
> ##########################
> #GB 2012
> ##########################
> 
> #GB R6 2012
> country<-"GB"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            271             239             200             139             128 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            160             156             176             151             177 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((9850-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((9850+(13190-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((13190+(16320-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((16320+(19650-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((19660+(23520-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((23520+(28000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((28000+(33790-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((33790+(41350-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((41350+(54910-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-54910

> table(data$income[data$cntry==country&data$essround==round])

 4924.5 11519.5 14754.5 17984.5 21589.5 25759.5 30894.5 37569.5 48129.5   54910 
    271     239     200     139     128     160     156     176     151     177 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),41350)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

          4924.5          11519.5          14754.5          17984.5          21589.5 
             271              239              200              139              128 
         25759.5          30894.5          37569.5          48129.5 101644.197815908 
             160              156              176              151              177 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="GBR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6959.25349658503  16279.240664821 20850.9098822954 25415.5131504383  30510.062618443 
             271              239              200              139              128 
36403.0643609061 43659.7943243469 53092.8366818867 68016.1216699947 143642.550321442 
             160              156              176              151              177 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 41769.53

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-34810.2767112152 -25490.2895429792 -20918.6203255048 -16354.0170573619 -11259.4675893573 
              271               239               200               139               128 
-5366.46584689416  1890.26411654663  11323.3064740865  26246.5914621945  101873.020113642 
              160               156               176               151               177 

> ##########################
> 
> 
> 
> ##########################
> #GB 2014
> ##########################
> 
> #GB R7 2014
> country<-"GB"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            283             265             218             163             172 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            160             154             153             153             180 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((10858-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((10858+(14548-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((14548+(18132-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((18132+(21715-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((21715+(25994-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((25994+(30754-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((30754+(36691-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((36691+(44714-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((44714+(58620-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-58620

> table(data$income[data$cntry==country&data$essround==round])

 5428.5 12702.5 16339.5   19923   23854 28373.5   33722   40702 51666.5   58620 
    283     265     218     163     172     160     154     153     153     180 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),44714)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top    #change

> table(data$income[select])

          5428.5          12702.5          16339.5            19923            23854 
             283              265              218              163              172 
         28373.5            33722            40702          51666.5 104711.276957561 
             160              154              153              153              180 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="GBR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7671.50118919927 17951.0442766517 23090.8158203779 28154.9817062572  33710.231070675 
             283              265              218              163              172 
40097.1426714093 47655.5886713048 57519.6539380655 73014.5742270911 147976.915483559 
             160              154              153              153              180 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 43509.4

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

  -35837.89721169 -25558.3541242376 -20418.5825805114 -15354.4166946321 -9799.16733021425 
              283               265               218               163               172 
-3412.25572947996  4146.19027041547  14010.2555371763  29505.1758262018   104467.51708267 
              160               154               153               153               180 

> ##########################
> 
> 
> 
> ##########################
> #Ireland 2002
> ##########################
> 
> #Ireland R1 2002
> country<-"IE"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         0          0          0          0          0          0          0          0 
         D          H          U          N    Refusal Don't know  No answer 
         0          0          0          0          0          0          0 

> #Ireland R2 2004
> country<-"IE"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         3          8         25        208        243        230        207        212 
         D          H          U          N    Refusal Don't know  No answer 
       367        174         60         36          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600)+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000)+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000)+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000)+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000)+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000)+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000)+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000)+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000)+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
       3        8       25      208      243      230      207      212      367      174 
104999.5   120000 
      60       36 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
               3                8               25              208              243 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             230              207              212              367              174 
        104999.5 169804.499913461 
              60               36 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="IRL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

889.091406899428 2668.26264916621 4743.96243181079 8895.36199709995 14825.9328046559 
               3                8               25              208              243 
20756.5036122118 26687.0744197678 32617.6452273237 47444.0722462136 74131.6408802153 
             230              207              212              367              174 
103784.494917995 167839.601696401 
              60               36 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 36880.36

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-35991.2728405336 -34212.1015982668 -32136.4018156222 -27985.0022503331 -22054.4314427771 
                3                 8                25               208               243 
-16123.8606352212 -10193.2898276652  -4262.7190201093  10563.7079987806  37251.2766327823 
              230               207               212               367               174 
  66904.130670562  130959.237448968 
               60                36 

> ##########################
> 
> 
> ##########################
> #Ireland 2006
> ##########################
> 
> #Ireland R3 2006
> country<-"IE"

> round<-3

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
              0               0               0               0               0 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
              0               0               0               0               0 
        Refusal      Don't know       No answer 
              0               0               0 

> #Ireland R4 2008
> country<-"IE"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             91             319             235             210             182 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            151             119             107              66              77 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((10000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((10000+(16000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((16000+(22000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((22000+(29000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((29000+(35000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((35000+(43000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((43000+(53000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((53000+(63000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((63000+(77000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-77000

> table(data$income[data$cntry==country&data$essround==round])

 4999.5 12999.5 18999.5 25499.5 31999.5 38999.5 47999.5 57999.5 69999.5   77000 
     91     319     235     210     182     151     119     107      66      77 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),63000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          4999.5          12999.5          18999.5          25499.5          31999.5 
              91              319              235              210              182 
         38999.5          47999.5          57999.5          69999.5 113933.093845548 
             151              119              107               66               77 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="IRL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

4941.64812539599 12849.0758688039 18779.6466763599 25204.4317178788 31629.2167593977 
              91              319              235              210              182 
38548.2160348797 47444.0722462136 57328.3569254735 69189.4985405854 112614.713395823 
             151              119              107               66               77 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 32658.84

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-27717.1890654954 -19809.7613220875 -13879.1905145315 -7454.40547301259 -1029.62043149365 
               91               319               235               210               182 
 5889.37884398828  14785.2350553222  24669.5197345821   36530.661349694  79955.8762049314 
              151               119               107                66                77 

> ##########################
> #Ireland 2010
> ##########################
> 
> #Ireland R5 2010
> country<-"IE"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            537             387             224             191             110 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
             78              87              70              42              16 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((14173-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((14173+(20775-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((20775+(25577-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((25577+(32777-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((32777+(38174-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((38174+(45636-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((45636+(54851-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((54851+(64951-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((64951+(85526-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-85526

> table(data$income[data$cntry==country&data$essround==round])

   7086 17473.5 23175.5 29176.5   35475 41904.5   50243 59900.5   75238   85526 
    537     387     224     191     110      78      87      70      42      16 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),64951)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

            7086          17473.5          23175.5          29176.5            35475 
             537              387              224              191              110 
         41904.5            50243          59900.5            75238 108767.270360707 
              78               87               70               42               16 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="IRL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7004.00412372357 17271.3048343048 22907.3239584188 28838.8831944427 35064.4998996745 
             537              387              224              191              110 
41419.6007342047 49661.6115140055 59207.3594430008 74367.3810698157 107508.666403125 
              78               87               70               42               16 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 23812.33

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-16808.3267135226 -6541.02600294138 -905.006878827378  5026.55235719649  11252.1690624283 
              537               387               224               191               110 
 17607.2698969585  25849.2806767594  35395.0286057546  50555.0502325695   83696.335565879 
               78                87                70                42                16 

> ##########################
> 
> 
> 
> ##########################
> #Ireland 2012
> ##########################
> 
> #Ireland R6 2012
> country<-"IE"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            369             391             328             236             169 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            173             114              71              36              45 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((13607-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((13607+(17881-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((17881+(24610-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((24610+(30042-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((30042+(35717-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((35717+(42399-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((42399+(51830-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((51830+(62818-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((62818+(83877-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-83877

> table(data$income[data$cntry==country&data$essround==round])

   6803 15743.5   21245 27325.5   32879 39057.5   47114 57323.5   73347   83877 
    369     391     328     236     169     173     114      71      36      45 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),61818)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

            6803          15743.5            21245          27325.5            32879 
             369              391              328              236              169 
         39057.5            47114          57323.5            73347 174439.427506998 
             173              114               71               36               45 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="IRL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6724.27886730051 15561.3235847928 20999.1628010877 27009.3021003117 32498.5395969386 
             369              391              328              236              169 
38605.5448860194 46568.8188378651 56660.1792811555 72498.2628369676 172420.896076629 
             173              114               71               36               45 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 27794.65

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-21070.3719801839 -12233.3272626916 -6795.48804639679   -785.3487471728  4703.88874945419 
              369               391               328               236               169 
 10810.8940385349  18774.1679903807  28865.5284336711  44703.6119894832  144626.245229144 
              173               114                71                36                45 

> ##########################
> 
> 
> 
> ##########################
> #Ireland 2014
> ##########################
> 
> #Ireland R7 2014
> country<-"IE"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            377             313             261             208             235 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            167             138             103              59              57 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((12816-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((12816+(17655-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((17655+(23551-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((23551+(28793-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((28793+(33506-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((33506+(40274-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((40274+(48170-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((48170+(58705-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((58705+(75072-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-75072

> table(data$income[data$cntry==country&data$essround==round])

 6407.5   15235 20602.5 26171.5   31149 36889.5 44221.5   53437   66888   75072 
    377     313     261     208     235     167     138     103      59      57 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),58705)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          6407.5            15235          20602.5          26171.5            31149 
             377              313              261              208              235 
         36889.5          44221.5            53437            66888 114807.837577339 
             167              138              103               59               57 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="IRL"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6333.35540823578 15058.7077088525 20364.0975104452 25868.6556483251 30788.5583474267 
             377              313              261              208              235 
36462.6319675558 43709.7894943892 52818.6520405612 66114.0033626337 113479.335002465 
             167              138              103               59               57 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 27613.48

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-21280.1229447465 -12554.7706441298 -7249.38084253707 -1744.82270465723  3175.07999444439 
              377               313               261               208               235 
 8849.15361457353  16096.3111414069  25205.1736875789  38500.5250096514   85865.856649483 
              167               138               103                59                57 

> ##########################
> 
> 
> 
> ##########################
> #Italy 2002
> ##########################
> 
> #Italy R1 2002
> country<-"IT"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         5         13         38        123        123        105         87         45 
         D          H          U          N    Refusal Don't know  No answer 
        69         21          4          4          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600)+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000)+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000)+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000)+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000)+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000)+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000)+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000)+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000)+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
       5       13       38      123      123      105       87       45       69       21 
104999.5   120000 
       4        4 

> ##########################
> 
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
               5               13               38              123              123 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             105               87               45               69               21 
        104999.5 205141.354962175 
               4                4 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="ITA"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1051.87577692048 3156.79673129164 5612.53784472466 10524.0200715907 17540.4232528279 
               5               13               38              123              123 
24556.8264340651 31573.2296153023 38589.6327965395 56130.6407496325 87704.4550651999 
             105               87               45               69               21 
122786.470971386 239892.409259985 
               4                4 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 28161.53

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-27109.6551812682  -25004.734226897  -22548.993113464 -17637.5108865979 -10621.1077053607 
                5                13                38               123               123 
-3604.70452412353  3411.69865711367  10428.1018383509  27969.1097914439  59542.9241070113 
              105                87                45                69                21 
 94624.9400131973  211730.878301797 
                4                 4 

> ##########################
> #Italy 2004
> ##########################
> 
> #Italy R2 2004
> country<-"IT"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         5         21         50        177        212        173        131         96 
         D          H          U          N    Refusal Don't know  No answer 
       104         38         14         11          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600)+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000)+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000)+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000)+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000)+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000)+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000)+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000)+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000)+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
       5       21       50      177      212      173      131       96      104       38 
104999.5   120000 
      14       11 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
               5               21               50              177              212 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             173              131               96              104               38 
        104999.5 184732.696629734 
              14               11 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="ITA"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1051.87577692048 3156.79673129164 5612.53784472466 10524.0200715907 17540.4232528279 
               5               21               50              177              212 
24556.8264340651 31573.2296153023 38589.6327965395 56130.6407496325 87704.4550651999 
             173              131               96              104               38 
122786.470971386 216026.513385232 
              14               11 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 30318.01

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-29266.1351312104 -27161.2141768392 -24705.4730634062 -19793.9908365401 -12777.5876553029 
                5                21                50               177               212 
-5761.18447406574  1255.21870717147  8271.62188840867  25812.6298415017  57386.4441570691 
              173               131                96               104                38 
 92468.4600632551  185708.502477102 
               14                11 

> ##########################
> 
> 
> 
> ##########################
> #Italy 2006
> ##########################
> 
> #Italy R3 2006
> country<-"IT"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         0          0          0          0          0          0          0          0 
         D          H          U          N    Refusal Don't know  No answer 
         0          0          0          0          0          0          0 

> #Italy R4 2008
> country<-"IT"

> round<-4

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         0          0          0          0          0          0          0          0 
         D          H          U          N    Refusal Don't know  No answer 
         0          0          0          0          0          0          0 

> #Italy R5 2010
> country<-"IT"

> round<-5

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         0          0          0          0          0          0          0          0 
         D          H          U          N    Refusal Don't know  No answer 
         0          0          0          0          0          0          0 

> #Italy R6 2012
> country<-"IT"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             94             100              76              62              52 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
             53              50              38              28              31 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((11710)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((11711+(15632))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((15633+(19200))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((19201+(23035))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((23036+(27000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((27001+(31952))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((31953+(37683))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((37684+(45340))/2) #mistake in showcard 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((45341+(58549))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-58550

> table(data$income[data$cntry==country&data$essround==round])

   5855 13671.5 17416.5   21118   25018 29476.5   34818   41512   51945   58550 
     94     100      76      62      52      53      50      38      28      31 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),45341)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

           5855         13671.5         17416.5           21118           25018 
             94             100              76              62              52 
        29476.5           34818           41512           51945 97142.889467671 
             53              50              38              28              31 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="ITA"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

 6846.8401043573 15987.4593487141 20366.8643343363 24695.4003968945 29256.0624646987 
              94              100               76               62               52 
34469.8347286231 40716.1876607195 48544.1548099198 60744.5105415611 113598.946449257 
              53               50               38               28               31 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 30432.3

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-23585.4592250656 -14444.8399807088 -10065.4349950866 -5736.89893252834 -1176.23686472416 
               94               100                76                62                52 
 4037.53539920018  10283.8883312966  18111.8554804969  30312.2112121382  83166.6471198339 
               53                50                38                28                31 

> ##########################
> 
> 
> 
> ##########################
> #Italy 2014
> ##########################
> 
> #Italy R7 2014
> country<-"IT"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
              0               0               0               0               0 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
              0               0               0               0               0 
        Refusal      Don't know       No answer 
              0               0               0 

> ##########################
> 
> 
> 
> ##########################
> #Netherlands 2002
> ##########################
> 
> #Netherlands R1 2002
> country<-"NL"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         9         25         28        181        336        320        310        283 
         D          H          U          N    Refusal Don't know  No answer 
       357        125         46         31          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600)+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000)+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000)+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000)+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000)+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000)+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000)+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000)+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000)+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
       9       25       28      181      336      320      310      283      357      125 
104999.5   120000 
      46       31 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
               9               25               28              181              336 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             320              310              283              357              125 
        104999.5 175489.218841051 
              46               31 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NLD"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1002.63169921272 3009.00975211199 5349.78414716114 10031.3329372594  16719.259780257 
               9               25               28              181              336 
23407.1866232546 30095.1134662522 36783.0403092497 53502.8574167437 83598.5282102327 
             320              310              283              357              125 
117038.162425221 195609.842890623 
              46               31 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 37003.79

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-36001.1554581495 -33994.7774052502 -31654.0030102011 -26972.4542201028 -20284.5273771052 
                9                25                28               181               336 
-13596.6005341076 -6908.67369111006 -220.746848112482  16499.0702593814  46594.7410528705 
              320               310               283               357               125 
 80034.3752678584  158606.055733261 
               46                31 

> ##########################
> 
> 
> 
> ##########################
> #Netherlands 2004
> ##########################
> 
> #Netherlands R2 2004
> country<-"NL"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         6         18         13        178        269        275        221        185 
         D          H          U          N    Refusal Don't know  No answer 
       306        108         28         25          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600)+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000)+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000)+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000)+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000)+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000)+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000)+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000)+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000)+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
       6       18       13      178      269      275      221      185      306      108 
104999.5   120000 
      28       25 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
               6               18               13              178              269 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             275              221              185              306              108 
        104999.5 194443.209869971 
              28               25 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NLD"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1002.63169921272 3009.00975211199 5349.78414716114 10031.3329372594  16719.259780257 
               6               18               13              178              269 
23407.1866232546 30095.1134662522 36783.0403092497 53502.8574167437 83598.5282102327 
             275              221              185              306              108 
117038.162425221 216736.993787998 
              28               25 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 37010.82

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-36008.1838442006 -34001.8057913013 -31661.0313962521 -26979.4826061538 -20291.5557631563 
                6                18                13               178               269 
-13603.6289201587 -6915.70207716112 -227.775234163542  16492.0418733304  46587.7126668195 
              275               221               185               306               108 
 80027.3468818073  179726.178244585 
               28                25 

> ##########################
> 
> 
> 
> ##########################
> #Netherlands 2006
> ##########################
> 
> #Netherlands R3 2006
> country<-"NL"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        18         24         36        175        233        255        244        210 
         D          H          U          N    Refusal Don't know  No answer 
       328         97         30         19          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600)+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000)+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000)+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000)+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000)+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000)+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000)+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000)+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000)+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      18       24       36      175      233      255      244      210      328       97 
104999.5   120000 
      30       19 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
              18               24               36              175              233 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             255              244              210              328               97 
        104999.5 172329.677315481 
              30               19 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NLD"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1002.63169921272 3009.00975211199 5349.78414716114 10031.3329372594  16719.259780257 
              18               24               36              175              233 
23407.1866232546 30095.1134662522 36783.0403092497 53502.8574167437 83598.5282102327 
             255              244              210              328               97 
117038.162425221 192088.045793886 
              30               19 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 35823.38

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-34820.7461188325 -32814.3680659332 -30473.5936708841 -25792.0448807858 -19104.1180377882 
               18                24                36               175               233 
-12416.1911947906 -5728.26435179304   959.66249120453  17679.4795986985  47775.1503921875 
              255               244               210               328                97 
 81214.7846071754  156264.667975841 
               30                19 

> ##########################
> 
> 
> 
> ##########################
> #Netherlands 2008
> ##########################
> 
> #Netherlands R4 2008
> country<-"NL"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             87             108             147             146             175 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            153             177             192             190             192 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((11700-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((11700+(15000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((15000+(18200-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((18200+(21500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((21500+(25300-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((25300+(29500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((29500+(34200-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((34200+(40200-1))/2) #mistake in showcard 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((40200+(50300-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-50300

> table(data$income[data$cntry==country&data$essround==round])

 5849.5 13349.5 16599.5 19849.5 23399.5 27399.5 31849.5 37199.5 45249.5   50300 
     87     108     147     146     175     153     177     192     190     192 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),40200)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          5849.5          13349.5          16599.5          19849.5          23399.5 
              87              108              147              146              175 
         27399.5          31849.5          37199.5          45249.5 74608.8782743369 
             153              177              192              190              192 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NLD"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6520.17134468572 14880.0798984327 18502.7069383897 22125.3339783467 26082.3573604536 
              87              108              147              146              175 
30540.9752557853 35501.1876643419  41464.589099348 50437.5576137031  83163.119956146 
             153              177              192              190              192 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 36475.46

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-29955.2902193614 -21595.3816656144 -17972.7546256574 -14350.1275857004 -10393.1042035935 
               87               108               147               146               175 
-5934.48630826176 -974.273899705229  4989.12753530094   13962.096049656  46687.6583920989 
              153               177               192               190               192 

> ##########################
> 
> 
> 
> ##########################
> #Netherlands 2010
> ##########################
> 
> #Netherlands R5 2010
> country<-"NL"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            109             136             115             174             190 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            165             178             129             160             126 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((13000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((13000+(17000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((17000+(20000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((20000+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((24000+(29000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((29000+(34000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((34000+(39000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((39000+(46000-1))/2) #mistake in showcard 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((46000+(58000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-58000

> table(data$income[data$cntry==country&data$essround==round])

 6499.5 14999.5 18499.5 21999.5 26499.5 31499.5 36499.5 42499.5 51999.5   58000 
    109     136     115     174     190     165     178     129     160     126 

> ##########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),46000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          6499.5          14999.5          18499.5          21999.5          26499.5 
             109              136              115              174              190 
         31499.5          36499.5          42499.5          51999.5 80868.3518302587 
             165              178              129              160              126 

> ##########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NLD"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7244.69675267712  16719.259780257 20620.5504386723 24521.8410970875 29537.7862293357 
             109              136              115              174              190 
35111.0585985003  40684.330967665 47372.2578106626 57961.4753120754 90140.2701590932 
             165              178              129              160              126 

> ##########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 37173.75

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-29929.0557706841 -20454.4927431042 -16553.2020846889 -12651.9114262737 -7635.96629402549 
              109               136               115               174               190 
-2062.69392486085   3510.5784443038  10198.5052873014  20787.7227887142   52966.517635732 
              165               178               129               160               126 

> ##########################
> 
> 
> 
> ##########################
> #Netherlands 2012
> #########################
> 
> #Netherlands R6 2012
> country<-"NL"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             89             148             134             169             162 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            172             169             168             167             188 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((11300-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((11300+(15600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((15600+(19300-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((19300+(23700-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((23700+(27300-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((27300+(32500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((32500+(38300-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((38300+(44700-1))/2) #mistake in showcard 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((44700+(54400-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-54400

> table(data$income[data$cntry==country&data$essround==round])

 5649.5 13449.5 17449.5 21499.5 25499.5 29899.5 35399.5 41499.5 49549.5   54400 
     89     148     134     169     162     172     169     168     167     188 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),44700)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          5649.5          13449.5          17449.5          21499.5          25499.5 
              89              148              134              169              162 
         29899.5          35399.5          41499.5          49549.5 78720.5373286322 
             172              169              168              167              188 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NLD"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6297.24044991913  14991.545345816 19450.1632411477 23964.5138601711 28423.1317555028 
              89              148              134              169              162 
33327.6114403677 39458.2110464488 46257.6033368296 55230.5718511847  87746.199115892 
             172              169              168              167              188 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 38270.71

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31973.4685541765 -23279.1636582796 -18820.5457629479 -14306.1951439245 -9847.57724859282 
               89               148               134               169               162 
-4943.09756372794  1187.50204235317  7986.89433273404  16959.8628470891  49475.4901117964 
              172               169               168               167               188 

> #########################
> 
> 
> 
> #########################
> #Netherlands 2014
> #########################
> 
> #Netherlands R7 2014
> country<-"NL"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            117             161             149             132             192 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            223             183             216             187             169 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((13000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((13000+(17000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((17000+(20500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((20500+(24200-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((24200+(28500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((28500+(33500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((33500+(39200-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((39200+(46400-1))/2) #mistake in showcard 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((46400+(58200-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-58200

> table(data$income[data$cntry==country&data$essround==round])

 6499.5 14999.5 18749.5 22349.5 26349.5 30999.5 36349.5 42799.5 52299.5   58200 
    117     161     149     132     192     223     183     216     187     169 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),46400)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          6499.5          14999.5          18749.5          22349.5          26349.5 
             117              161              149              132              192 
         30999.5          36349.5          42799.5          52299.5 83636.1998265556 
             223              183              216              187              169 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NLD"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7244.69675267712  16719.259780257 20899.2140571305  24911.970162929 29370.5880582608 
             117              161              149              132              192 
34553.7313615839   40517.13279659 47706.6541528124 58295.8716542253  93225.464311055 
             223              183              216              187              169 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 39133.68

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31888.9830438612 -22414.4200162814 -18234.4657394079 -14221.7096336093 -9763.09173827761 
              117               161               149               132               192 
-4579.94843495449  1383.45300005168  8572.97435627407  19162.1918576869  54091.7845145166 
              223               183               216               187               169 

> #########################
> 
> 
> 
> #########################
> #Norway 2002
> #########################
> 
> #Norway R1 2002
> country<-"NO"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        18         27         38         62        126        147        176        256 
         D          H          U          N    Refusal Don't know  No answer 
       617        347         97         61          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((12900-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((12900+(25800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((25800)+(43000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((43000)+(85900-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((85900)+(128900-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((128900)+(171800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((171800)+(214800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((214800)+(257700-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((257700)+(429500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((429500)+(644300-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((644300)+(859000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-859000 

> table(data$income[data$cntry==country&data$essround==round])

  6449.5  19349.5  34399.5  64449.5 107399.5 150349.5 193299.5 236249.5 343599.5 536899.5 
      18       27       38       62      126      147      176      256      617      347 
751649.5   859000 
      97       61 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),644300)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

          6449.5          19349.5          34399.5          64449.5         107399.5 
              18               27               38               62              126 
        150349.5         193299.5         236249.5         343599.5         536899.5 
             147              176              256              617              347 
        751649.5 1231001.23869051 
              97               61 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NOR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

716.196990095949 2148.70201718917 3819.95788213127  7156.9172669492 11926.3816788604 
              18               27               38               62              126 
16695.8460907715 21465.3105026827 26234.7749145938 38155.6597718386 59621.0257979719 
             147              176              256              617              347 
83468.3478575277 136698.873083887 
              97               61 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 38426.17

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-37709.9710095306 -36277.4659824374 -34606.2101174953 -31269.2507326774 -26499.7863207662 
               18                27                38                62               126 
-21730.3219088551 -16960.8574969439 -12191.3930850328 -270.508227787999  21194.8577983453 
              147               176               256               617               347 
 45042.1798579011  98272.7050842606 
               97                61 

> #########################
> 
> 
> 
> #########################
> #Norway 2004
> #########################
> 
> #Norway R2 2004
> country<-"NO"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        14         29         29         43         75        118        128        183 
         D          H          U          N    Refusal Don't know  No answer 
       534        357        122         76          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((12900-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((12900+(25800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((25800)+(43000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((43000)+(85900-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((85900)+(128900-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((128900)+(171800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((171800)+(214800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((214800)+(257700-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((257700)+(429500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((429500)+(644300-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((644300)+(859000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-859000 

> table(data$income[data$cntry==country&data$essround==round])

  6449.5  19349.5  34399.5  64449.5 107399.5 150349.5 193299.5 236249.5 343599.5 536899.5 
      14       29       29       43       75      118      128      183      534      357 
751649.5   859000 
     122       76 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),644300)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

         6449.5         19349.5         34399.5         64449.5        107399.5 
             14              29              29              43              75 
       150349.5        193299.5        236249.5        343599.5        536899.5 
            118             128             183             534             357 
       751649.5 1227773.6362231 
            122              76 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NOR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

716.196990095949 2148.70201718917 3819.95788213127  7156.9172669492 11926.3816788604 
              14               29               29               43               75 
16695.8460907715 21465.3105026827 26234.7749145938 38155.6597718386 59621.0257979719 
             118              128              183              534              357 
83468.3478575277 136340.457831172 
             122               76 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 42803.76

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-42087.5612754692  -40655.056248376 -38983.8003834339  -35646.840998616 -30877.3765867048 
               14                29                29                43                75 
-26107.9121747937 -21338.4477628825 -16568.9833509714 -4648.09849372659  16817.2675324067 
              118               128               183               534               357 
 40664.5895919625  93536.6995656071 
              122                76 

> #########################
> 
> 
> 
> #########################
> #Norway 2006
> #########################
> 
> #Norway R3 2006
> country<-"NO"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        16         13         34         42         87         88        103        157 
         D          H          U          N    Refusal Don't know  No answer 
       487        386        168        105          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((12900-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((12900+(25800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((25800)+(43000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((43000)+(85900-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((85900)+(128900-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((128900)+(171800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((171800)+(214800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((214800)+(257700-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((257700)+(429500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((429500)+(644300-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((644300)+(859000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-859000 

> table(data$income[data$cntry==country&data$essround==round])

  6449.5  19349.5  34399.5  64449.5 107399.5 150349.5 193299.5 236249.5 343599.5 536899.5 
      16       13       34       42       87       88      103      157      487      386 
751649.5   859000 
     168      105 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),644300)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

          6449.5          19349.5          34399.5          64449.5         107399.5 
              16               13               34               42               87 
        150349.5         193299.5         236249.5         343599.5         536899.5 
              88              103              157              487              386 
        751649.5 1228890.18509239 
             168              105 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NOR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

716.196990095949 2148.70201718917 3819.95788213127  7156.9172669492 11926.3816788604 
              16               13               34               42               87 
16695.8460907715 21465.3105026827 26234.7749145938 38155.6597718386 59621.0257979719 
              88              103              157              487              386 
83468.3478575277 136464.447123285 
             168              105 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 47006.79

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-46290.5938352882  -44858.088808195 -43186.8329432529  -39849.873558435 -35080.4091465238 
               16                13                34                42                87 
-30310.9447346127 -25541.4803227015 -20772.0159107903 -8851.13105354558  12614.2349725878 
               88               103               157               487               386 
 36461.5570321435  89457.6562979004 
              168               105 

> #########################
> 
> 
> 
> #########################
> #Norway 2008
> #########################
> 
> #Norway R4 2008
> country<-"NO"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             29              78             110             127             176 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            182             186             179             190             224 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((125000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((125000+(170000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((170000+(220000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((220000+(270000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((270000+(325000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((325000+(400000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((400000+(475000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((475000+(550000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((550000+(670000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-670000

> table(data$income[data$cntry==country&data$essround==round])

 62499.5 147499.5 194999.5 244999.5 297499.5 362499.5 437499.5 512499.5 609999.5   670000 
      29       78      110      127      176      182      186      179      190      224 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),550000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

         62499.5         147499.5         194999.5         244999.5         297499.5 
              29               78              110              127              176 
        362499.5         437499.5         512499.5         609999.5 987206.414981447 
             182              186              179              190              224 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NOR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6940.37580936534 16379.3624219951 21654.0902349353 27206.4353011881 33036.3976207535 
              29               78              110              127              176 
40254.4462068822 48582.9638062614 56911.4814056406 67738.5542848335 109626.213351907 
             182              186              179              190              224 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 52064.1

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-45123.7208225766 -35684.7342099468 -30410.0063970066 -24857.6613307538 -19027.6990111884 
               29                78               110               127               176 
-11809.6504250598 -3481.13282568056  4847.38477369864  15674.4576528916  57562.1167199652 
              182               186               179               190               224 

> #########################
> 
> 
> 
> #########################
> #Norway 2010
> #########################
> 
> #Norway R5 2010
> country<-"NO"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            111             194             198             189             184 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            150             125             116             100             108 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((205000)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((205001+(295000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((295001+(370000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((370001+(450000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((450001+(530000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((530001+(600000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((600001+(675000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((675001+(775000))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((775001+(935000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-935001

> table(data$income[data$cntry==country&data$essround==round])

  102500 250000.5 332500.5 410000.5 490000.5 565000.5 637500.5 725000.5 855000.5   935001 
     111      194      198      189      184      150      125      116      100      108 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),775001)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          102500         250000.5         332500.5         410000.5         490000.5 
             111              194              198              189              184 
        565000.5         637500.5         725000.5         855000.5 1310188.53305247 
             150              125              116              100              108 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NOR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

11382.3073858182 27761.7808547147 36923.1502140318 45529.2850667236 54413.0371727281 
             111              194              198              189              184 
62741.5547721073 70792.4551181739 80509.0589841163 94945.1561563736 145492.376747098 
             150              125              116              100              108 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 57887.51

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-46505.1992701009 -30125.7258012045 -20964.3564418874 -12358.2215891955 -3474.46948319105 
              111               194               198               189               184 
 4854.04811618816  12904.9484622547  22621.5523281971  37057.6495004544  87604.8700911788 
              150               125               116               100               108 

> #########################
> 
> 
> 
> #########################
> #Norway 2012
> #########################
> 
> #Norway R6 2012
> country<-"NO"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            135             161             175             181             189 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            175             142             155             107             135 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((216000)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((216001+(311000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((311001+(390000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((390001+(470000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((470001+(550000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((550001+(626000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((626001+(706000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((706001+(807000))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((807001+(973000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-973001

> table(data$income[data$cntry==country&data$essround==round])

  108000 263500.5 350500.5 430000.5 510000.5 588000.5 666000.5 756500.5 890000.5   973001 
     135      161      175      181      189      175      142      155      107      135 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),807001)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          108000         263500.5         350500.5         430000.5         510000.5 
             135              161              175              181              189 
        588000.5         666000.5         756500.5         890000.5 1431923.09849484 
             175              142              155              107              135 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NOR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

11993.0653431061 29260.9140226029 38921.9944378828 47750.2230932248 56633.9751992292 
             135              161              175              181              189 
65295.6335025836  73957.291805938 84007.0363758555 98831.7977027505 159010.623023625 
             175              142              155              107              135 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 63973.78

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-51980.7160704968 -34712.8673909999 -25051.7869757201 -16223.5583203781 -7339.80621437363 
              135               161               175               181               189 
 1321.85208898074  9983.51039233512  20033.2549622527  34858.0162891477  95036.8416100218 
              175               142               155               107               135 

> #########################
> 
> 
> 
> #########################
> #Norway 2014
> #########################
> 
> #Norway R7 2014
> country<-"NO"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            124             158             150             172             137 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            135             117             134             108             136 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((231000)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((231001+(331000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((331001+(417000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((417001+(502000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((502001+(588000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((588001+(672000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((672001+(761000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((761001+(871000))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((871001+(1053000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-1053001

> table(data$income[data$cntry==country&data$essround==round])

  115500 281000.5 374000.5 459500.5 545000.5 630000.5 716500.5 816000.5 962000.5  1053001 
     124      158      150      172      137      135      117      134      108      136 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),871001)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          115500         281000.5         374000.5         459500.5         545000.5 
             124              158              150              172              137 
        630000.5         716500.5         816000.5         962000.5 1559169.63305589 
             135              117              134              108              136 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="NOR"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

 12825.917103044 31204.2347957914 41531.5966190216 51026.1066823139 60520.6167456062 
             124              158              150              172              137 
 69959.603358236 79565.1603228533 90614.3270046964 106827.174598155 173140.956390982 
             135              117              134              108              136 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 69875.08

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-57049.1610227117 -38670.8433299642  -28343.481506734 -18848.9714434417 -9354.46138014943 
              124               158               150               172               137 
 84.5252324803296  9690.08219709767  20739.2488789408  36952.0964723989  103265.878265226 
              135               117               134               108               136 

> #########################
> 
> 
> #########################
> #Portugal 2002
> #########################
> 
> #Portugal R1 2002
> country<-"PT"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        39        114        177        258        170        116         64         44 
         D          H          U          N    Refusal Don't know  No answer 
        44         16          7          4          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600)+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000)+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000)+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000)+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000)+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000)+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000)+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000)+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000)+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      39      114      177      258      170      116       64       44       44       16 
104999.5   120000 
       7        4 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
              39              114              177              258              170 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             116               64               44               44               16 
        104999.5 167687.457244641 
               7                4 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="PRT"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1354.14047833752 4063.92687189786 7225.34433105159 13548.1792493591 22580.8005612269 
              39              114              177              258              170 
31613.4218730947 40646.0431849625 49678.6644968303 72260.2177764998 112907.013679905 
             116               64               44               44               16 
158070.120239244 252442.883340145 
               7                4 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 23443.25

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-22089.1079029044  -19379.321509344 -16217.9040501903 -9895.06913188285 -862.447820015041 
               39               114               177               258               170 
 8170.17349185277  17202.7948037206  26235.4161155884  48816.9693952579  89463.7652986631 
              116                64                44                44                16 
 134626.871858002  228999.634958903 
                7                 4 

> #########################
> 
> 
> 
> #########################
> #Portugal 2004
> #########################
> 
> #Portugal R2 2004
> country<-"PT"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        46        146        245        366        197         84         45         29 
         D          H          U          N    Refusal Don't know  No answer 
        18         16          6          9          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600)+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000)+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000)+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000)+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000)+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000)+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000)+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000)+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000)+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      46      146      245      366      197       84       45       29       18       16 
104999.5   120000 
       6        9 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
              46              146              245              366              197 
         20999.5          26999.5          32999.5          47999.5          74999.5 
              84               45               29               18               16 
        104999.5 274706.907239292 
               6                9 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="PRT"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1354.14047833752 4063.92687189786 7225.34433105159 13548.1792493591 22580.8005612269 
              46              146              245              366              197 
31613.4218730947 40646.0431849625 49678.6644968303 72260.2177764998 112907.013679905 
              84               45               29               18               16 
158070.120239244 413553.910807821 
               6                9 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 21156.39

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-19802.2532009235 -17092.4668073631 -13931.0493482094 -7608.21442990194  1424.40688196586 
               46               146               245               366               197 
 10457.0281938337  19489.6495057015  28522.2708175693  51103.8240972388   91750.620000644 
               84                45                29                18                16 
 136913.726559983   392397.51712856 
                6                 9 

> #########################
> 
> 
> 
> #########################
> #Portugal 2006
> #########################
> 
> #Portugal R3 2006
> country<-"PT"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
        46        107        223        320        180        136         84         46 
         D          H          U          N    Refusal Don't know  No answer 
        34         14         14          8          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1800-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1800+(3600-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((3600)+(6000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((6000)+(12000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((12000)+(18000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((18000)+(24000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((24000)+(30000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((30000)+(36000-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((36000)+(60000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((60000)+(90000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((90000)+(120000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-120000 

> table(data$income[data$cntry==country&data$essround==round])

   899.5   2699.5   4799.5   8999.5  14999.5  20999.5  26999.5  32999.5  47999.5  74999.5 
      46      107      223      320      180      136       84       46       34       14 
104999.5   120000 
      14        8 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),90000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

           899.5           2699.5           4799.5           8999.5          14999.5 
              46              107              223              320              180 
         20999.5          26999.5          32999.5          47999.5          74999.5 
             136               84               46               34               14 
        104999.5 167687.457244641 
              14                8 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="PRT"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

1354.14047833752 4063.92687189786 7225.34433105159 13548.1792493591 22580.8005612269 
              46              107              223              320              180 
31613.4218730947 40646.0431849625 49678.6644968303 72260.2177764998 112907.013679905 
             136               84               46               34               14 
158070.120239244 252442.883340145 
              14                8 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 23743.67

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-22389.5276727013 -19679.7412791409 -16518.3238199872 -10195.4889016797 -1162.86758981191 
               46               107               223               320               180 
  7869.7537220559  16902.3750339237  25934.9963457915   48516.549625461  89163.3455288662 
              136                84                46                34                14 
 134326.452088205  228699.215189106 
               14                 8 

> #########################
> 
> 
> 
> #########################
> #Portugal 2008
> #########################
> 
> #Portugal R4 2008
> country<-"PT"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             45             121             166             259             168 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
             97              59              45              22               9 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((5000-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((5000+(7000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((7000+(9000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((9000+(11000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((11000+(13800-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((13800+(16000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((16000+(19500-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((19500+(24500-1))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((24500+(35000-1))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-35000

> table(data$income[data$cntry==country&data$essround==round])

 2499.5  5999.5  7999.5  9999.5 12399.5 14899.5 17749.5 21999.5 29749.5   35000 
     45     121     166     259     168      97      59      45      22       9 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),24500)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          2499.5           5999.5           7999.5           9999.5          12399.5 
              45              121              166              259              168 
         14899.5          17749.5          21999.5          29749.5 49184.5219243616 
              97               59               45               22                9 

> #########################
> 
> 
> #3) Adjust to PPP
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="PRT"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

 3762.8394948356 9031.86859342515 12042.7423640478 15053.6161346704 18666.6646594175 
              45              121              166              259              168 
22430.2568726957  26720.751995833  33118.858758406 44785.9946195686 74044.1934913364 
              97               59               45               22                9 

> #########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 17346.58

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-13583.7426471948 -8314.71354860529 -5303.83977798269 -2292.96600736008  1320.08251738704 
               45               121               166               259               168 
 5083.67473066529   9374.1698538025  15772.2766163755  27439.4124775381   56697.611349306 
               97                59                45                22                 9 

> #########################
> 
> 
> 
> #########################
> #Portugal 2010
> #########################
> 
> #Portugal R5 2010
> country<-"PT"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
              0               0               0               0               0 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
              0               0               0               0               0 
        Refusal      Don't know       No answer 
              0               0               0 

> #Portugal R6 2012
> country<-"PT"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            156             213             219             171             119 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
             59              31              21              16               9 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((5500-1)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((5500+(7500))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((7501+(10000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((10001+(12000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((12001+(14000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((14001+(17000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((17001+(20000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((20001+(25000))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((25001+(35000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-35001

> table(data$income[data$cntry==country&data$essround==round])

 2749.5    6500  8750.5 11000.5 13000.5 15500.5 18500.5 22500.5 30000.5   35001 
    156     213     219     171     119      59      31      21      16       9 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),25001)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          2749.5             6500           8750.5          11000.5          13000.5 
             156              213              219              171              119 
         15500.5          18500.5          22500.5          30000.5 52188.1410989018 
              59               31               21               16                9 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="PRT"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

4139.19871616342 9785.33975452346 13173.3254649165  16560.558456867 19571.4322274896 
             156              213              219              171              119 
23335.0244407678 27851.3350967017 33873.0826379469 45163.8592777817 78565.9525861174 
              59               31               21               16                9 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 14947.75

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

 -10808.547302147 -5162.40626378693 -1774.42055339384  1612.81243855659  4623.68620917919 
              156               213               219               171               119 
 8387.27842245745  12903.5890783913  18925.3366196366  30216.1132594713   63618.206567807 
               59                31                21                16                 9 

> #########################
> #Portugal 2014
> #########################
> 
> #Portugal R7 2014
> country<-"PT"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            126             175             117             129             124 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
             93              90              81              95              39 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((5099)/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((5100+(7400))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((7401+(9400))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((9401+(11600))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((11601+(14000))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((14001+(16750))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((16751+(20100))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((20101+(24900))/2) 

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((24901+(37800))/2)

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-37801

> table(data$income[data$cntry==country&data$essround==round])

 2549.5    6250  8400.5 10500.5 12800.5 15375.5 18425.5 22500.5 31350.5   37801 
    126     175     117     129     124      93      90      81      95      39 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),24901)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

          2549.5             6250           8400.5          10500.5          12800.5 
             126              175              117              129              124 
         15375.5          18425.5          22500.5          31350.5 57118.0957536903 
              93               90               81               95               39 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="PRT"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

3838.11133910116 9408.98053319564 12646.4225550576 15807.8400142113 19270.3448504273 
             126              175              117              129              124 
23146.8448301039 27738.4273303034 33873.0826379469  47196.199072952 85987.6881663482 
              93               90               81               95               39 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 21766.63

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-17928.5235133616 -12357.6543192671 -9120.21229740514 -5958.79483825141 -2496.29000203541 
              126               175               117               129               124 
 1380.20997764119  5971.79247784066  12106.4477854842  25429.5642204892  64221.0533138855 
               93                90                81                95                39 

> #########################
> 
> 
> 
> #########################
> #Sweden 2002
> #########################
> 
> #Sweden R1 2002
> country<-"SE"

> round<-1

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         5         11         18        187        271        301        275        312 
         D          H          U          N    Refusal Don't know  No answer 
       400         74         11          1          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1400-1)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1400+(2800-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((2800)+(4700-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((4700)+(9400-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((9400)+(14100-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((14100)+(19000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((19000)+(23000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((23000)+(28000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((28000)+(47000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((47000)+(70000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((70000)+(94000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-94000*12 

> table(data$income[data$cntry==country&data$essround==round])

   8394   25194   44994   84594  140994  198594  251994  305994  449994  701994  983994 
      5      11      18     187     271     301     275     312     400      74      11 
1128000 
      1 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),840000)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

            8394            25194            44994            84594           140994 
               5               11               18              187              271 
          198594           251994           305994           449994           701994 
             301              275              312              400               74 
          983994 1279834.52896721 
              11                1 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="SWE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

885.519446720192 2657.82427217876  4746.6121021835 8924.18776219298  14874.068247661 
               5               11               18              187              271 
20950.5419349476 26583.9394158694 32280.6334977005 47471.8177159168 74056.3900977954 
             301              275              312              400               74 
103805.792525136 135015.292349826 
              11                1 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 29610.31

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-28724.7867513017 -26952.4819258431 -24863.6940958384 -20686.1184358289 -14736.2379503609 
                5                11                18               187               271 
-8659.76426307436 -3026.36678215248  2670.32729967863  17861.5115178949  44446.0838997735 
              301               275               312               400                74 
 74195.4863271137  105404.986151804 
               11                 1 

> #########################
> 
> 
> #########################
> #Sweden 2004
> #########################
> 
> #Sweden R2 2004
> country<-"SE"

> round<-2

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         8         10         16        146        234        303        247        325 
         D          H          U          N    Refusal Don't know  No answer 
       408         76         21         13          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1400-1)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1400+(2800-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((2800)+(4700-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((4700)+(9400-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((9400)+(14100-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((14100)+(19000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((19000)+(23000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((23000)+(28000-1))/2)*12 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((28000)+(47000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((47000)+(70000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((70000)+(94000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-94000*12 

> table(data$income[data$cntry==country&data$essround==round])

   8394   25194   44994   84594  140994  198594  251994  305994  449994  701994  983994 
      8      10      16     146     234     303     247     325     408      76      21 
1128000 
     13 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),70000*12)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

            8394            25194            44994            84594           140994 
               8               10               16              146              234 
          198594           251994           305994           449994           701994 
             303              247              325              408               76 
          983994 1626842.00624935 
              21               13 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="SWE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

885.519446720192 2657.82427217876  4746.6121021835 8924.18776219298  14874.068247661 
               8               10               16              146              234 
20950.5419349476 26583.9394158694 32280.6334977005 47471.8177159168 74056.3900977954 
             303              247              325              408               76 
103805.792525136 171622.615353239 
              21               13 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 31934.88

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-31049.3602555882 -29277.0554301297 -27188.2676001249 -23010.6919401155 -17060.8114546474 
                8                10                16               146               234 
-10984.3377673609 -5350.94028643901  345.753795392102  15536.9380136084  42121.5103954869 
              303               247               325               408                76 
 71870.9128228272  139687.735650931 
               21                13 

> #########################
> 
> 
> 
> #########################
> #Sweden 2006
> #########################
> 
> #Sweden R3 2006
> country<-"SE"

> round<-3

> table(data$hinctnt[data$cntry==country&data$essround==round])

         J          R          C          M          F          S          K          P 
         7          7         15        133        218        234        189        291 
         D          H          U          N    Refusal Don't know  No answer 
       518        132         19         18          0          0          0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnt=="J"]<-((1400-1)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="R"]<-((1400+(2800-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="C"]<-(((2800)+(4700-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="M"]<-(((4700)+(9400-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="F"]<-(((9400)+(14100-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="S"]<-(((14100)+(19000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="K"]<-(((19000)+(23000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="P"]<-(((23000)+(28000-1))/2)*12 

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="D"]<-(((28000)+(47000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="H"]<-(((47000)+(70000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="U"]<-(((70000)+(94000-1))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-94000*12 

> table(data$income[data$cntry==country&data$essround==round])

   8394   25194   44994   84594  140994  198594  251994  305994  449994  701994  983994 
      7       7      15     133     218     234     189     291     518     132      19 
1128000 
     18 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation(table(data$income[select]),70000*12)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnt=="N"]<-top   #change

> table(data$income[select])

            8394            25194            44994            84594           140994 
               7                7               15              133              218 
          198594           251994           305994           449994           701994 
             234              189              291              518              132 
          983994 1909060.54169804 
              19               18 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="SWE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

885.519446720192 2657.82427217876  4746.6121021835 8924.18776219298  14874.068247661 
               7                7               15              133              218 
20950.5419349476 26583.9394158694 32280.6334977005 47471.8177159168 74056.3900977954 
             234              189              291              518              132 
103805.792525136  201395.07203238 
              19               18 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 35827.73

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-34942.2113631894 -33169.9065377309 -31081.1187077261 -26903.5430477166 -20953.6625622486 
                7                 7                15               133               218 
-14877.1888749621  -9243.7913940402 -3547.09731220909  11644.0869060072  38228.6592878857 
              234               189               291               518               132 
  67978.061715226   165567.34122247 
               19                18 

> #########################
> 
> 
> 
> #########################
> #Sweden 2008
> #########################
> 
> #Sweden R4 2008
> country<-"SE"

> round<-4

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
             55              76              80              97             136 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            166             251             303             316             250 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((8099)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((8100+(10199))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((10200+(12399))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((12400+(14999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((15000+(17699))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((17700+(20999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((21000+(26299))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((26300+(33099))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((33100+(41199))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-41200*12

> table(data$income[data$cntry==country&data$essround==round])

 48594 109794 135594 164394 196194 232194 283794 356394 445794 494400 
    55     76     80     97    136    166    251    303    316    250 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),397200)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

           48594           109794           135594           164394           196194 
              55               76               80               97              136 
          232194           283794           356394           445794 675311.935609341 
             166              251              303              316              250 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="SWE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

5126.39170763891 11582.6450003808 14304.3988394779 17342.6356831212 20697.3555313106 
              55               76               80               97              136 
24495.1515858647 29938.6592640589 37597.5479740762 47028.7415095522 71241.5834625119 
             166              251              303              316              250 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 36097.11

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-30970.7148484028 -24514.4615556609 -21792.7077165638 -18754.4708729206 -15399.7510247311 
               55                76                80                97               136 
-11601.9549701771 -6158.44729198288   1500.4414180345  10931.6349535105  35144.4769064702 
              166               251               303               316               250 

> #########################
> 
> 
> 
> #########################
> #Sweden 2010
> #########################
> 
> #Sweden R5 2010
> country<-"SE"

> round<-5

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            149              85              92             114             136 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            141             128             134             182             239 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((11499)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((11500+(13999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((14000+(16999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((17000+(19999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((20000+(23999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((24000+(27999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((28000+(31999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((32000+(35999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((36000+(43999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-44000*12

> table(data$income[data$cntry==country&data$essround==round])

 68994 152994 185994 221994 263994 311994 359994 407994 479994 528000 
   149     85     92    114    136    141    128    134    182    239 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),36000*12)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

           68994           152994           185994           221994           263994 
             149               85               92              114              136 
          311994           359994           407994           479994 817889.294182712 
             141              128              134              182              239 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="SWE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

7278.47613855288 16140.0002658457 19621.3133158536 23419.1093704077 27849.8714340541 
             149               85               92              114              136 
32913.5995067929 37977.3275795317 43041.0556522704 50636.6477613786 86282.6870696978 
             141              128              134              182              239 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 39875.55

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

 -32597.069429896 -23735.5453026031 -20254.2322525952 -16456.4361980411 -12025.6741343947 
              149                85                92               114               136 
-6961.94606165596  -1898.2179889172  3165.51008382157  10761.1021929297  46407.1415012489 
              141               128               134               182               239 

> #########################
> 
> 
> 
> #########################
> #Sweden 2012
> #########################
> 
> #Sweden R6 2012
> country<-"SE"

> round<-6

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            104             143             157             139             126 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            161             147             211             261             226 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((10999)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((11000+(14999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((15000+(18999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((19000+(21999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((22000+(24999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((25000+(28999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((29000+(32999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((33000+(39999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((40000+(48999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-49000*12

> table(data$income[data$cntry==country&data$essround==round])

 65994 155994 203994 245994 281994 323994 371994 437994 533994 588000 
   104    143    157    139    126    161    147    211    261    226 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),40000*12)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

           65994           155994           203994           245994           281994 
             104              143              157              139              126 
          323994           371994           437994           533994 799281.325294912 
             161              147              211              261              226 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="SWE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6961.99313400671 16456.4832703919 21520.2113431307 25950.9734067771 29748.7694613312 
             104              143              157              139              126 
34179.5315249776 39243.2595977163 46205.8856977321 56333.3418432097 84319.6517689936 
             161              147              211              261              226 

> #########################
> 
> 
> #4) Distance to mean
> 
> mean(data$income.PPP[select],na.rm=T)
[1] 40950.37

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-33988.3811762151 -24493.8910398299 -19430.1629670911 -14999.4009034447 -11201.6048488906 
              104               143               157               139               126 
-6770.84278524418 -1707.11471250542  5255.51138751039  15382.9675329879  43369.2774587718 
              161               147               211               261               226 

> #########################
> 
> 
> 
> #########################
> #Sweden 2014
> #########################
> 
> #Sweden R7 2014
> country<-"SE"

> round<-7

> table(data$hinctnta[data$cntry==country&data$essround==round])

 J - 1st decile  R - 2nd decile  C - 3rd decile  M - 4th decile  F - 5th decile 
            119             127             117             132             118 
 S - 6th decile  K - 7th decile  P - 8th decile  D - 9th decile H - 10th decile 
            154             142             226             232             276 
        Refusal      Don't know       No answer 
              0               0               0 

> #1) Midpoints
> data$income[data$cntry==country&data$essround==round&data$hinctnta=="J - 1st decile"]<-((10999)/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="R - 2nd decile"]<-((11000+(14999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="C - 3rd decile"]<-((15000+(18999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="M - 4th decile"]<-((19000+(21999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="F - 5th decile"]<-((22000+(24999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="S - 6th decile"]<-((25000+(28999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="K - 7th decile"]<-((29000+(32999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="P - 8th decile"]<-((33000+(39999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="D - 9th decile"]<-((40000+(48999))/2)*12

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-49000*12

> table(data$income[data$cntry==country&data$essround==round])

 65994 155994 203994 245994 281994 323994 371994 437994 533994 588000 
   119    127    117    132    118    154    142    226    232    276 

> #########################
> 
> 
> #2) Interpolation top income
> 
> select<-data$cntry==country&data$essround==round                      

> top<-interpolation_change(table(data$income[select]),40000*12)         #change

> data$income[data$cntry==country&data$essround==round&data$hinctnta=="H - 10th decile"]<-top   #change

> table(data$income[select])

           65994           155994           203994           245994           281994 
             119              127              117              132              118 
          323994           371994           437994           533994 881091.548606652 
             154              142              226              232              276 

> #########################
> 
> 
> #3) Adjust to PPP
> 
> data$income.PPP[select]<-(data$income[select])/PPP$Value[PPP$LOCATION=="SWE"&PPP$TIME==2005]  #change location

> table(data$income.PPP[select])

6961.99313400671 16456.4832703919 21520.2113431307 25950.9734067771 29748.7694613312 
             119              127              117              132              118 
34179.5315249776 39243.2595977163 46205.8856977321 56333.3418432097 92950.1668610911 
             154              142              226              232              276 

> #########################
> 
> 
> #4) Distance to mean
> mean(data$income.PPP[select],na.rm=T)
[1] 44050.21

> data$income_dist[select]<-data$income.PPP[select]-mean(data$income.PPP[select],na.rm=T)

> table(data$income_dist[select])

-37088.2203889757 -27593.7302525905 -22530.0021798517 -18099.2401162053 -14301.4440616512 
              119               127               117               132               118 
-9870.68199800479 -4806.95392526603  2155.67217474977  12283.1283202273  48899.9533381088 
              154               142               226               232               276 

> #########################
> 
> 
> 
> 
> #########################
> #Country selection
> #########################
> 
> summary(data$income_dist)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
 -57049  -16808   -5691       0    9690  392398  181553 

> data<-data[data$cntry=="AT"|data$cntry=="BE"|data$cntry=="CH"|data$cntry=="DE"|
+              data$cntry=="DK"|data$cntry=="ES"|data$cntry=="FI"|data$cntry=="FR"|
+              data$cntry=="GB"|data$cntry=="IE"|data$cntry=="IT"|data$cntry=="NL"|
+              data$cntry=="NO"|data$cntry=="PT"|data$cntry=="SE",]

> summary(data$income)
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max.      NA's 
    594.5   17416.5   32994.0  111957.6   86475.4 1909060.5     42050 

> data %>%
+   group_by(cntry,essround) %>%
+   summarise(income=mean(income.PPP,na.rm=T))
# A tibble: 98 × 3
# Groups:   cntry [15]
   cntry essround income
   <chr> <fct>     <dbl>
 1 AT    1        28602.
 2 AT    2        32808.
 3 AT    3        31874.
 4 AT    7        35048.
 5 BE    1        31639.
 6 BE    2        34198.
 7 BE    3        37104.
 8 BE    4        39707.
 9 BE    5        35916.
10 BE    6        36960.
# … with 88 more rows
# ℹ Use `print(n = ...)` to see more rows

> #########################
> #Save file
> #########################
> 
> 
> save(data,file="DataFile_01_Income.Rda")

> #########################
> 
> 

> ################
> #PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
> #
> #Observational Data
> #Part II: Tax and Benefit Systems
> #
> #Verena Fetscher
> #July 2022
> ####################
> 
> rm(list=ls())

> ##########################
> #Load Data
> ##########################
> 
> #Import Social Insurance data
> #https://stats.oecd.org/Index.aspx?DataSetCode=FIXINCLSA#
> #Accessed 11-2017
> 
> Ins_single<-read.csv("TaxBen_OECD_single.csv", header = TRUE, sep = ",", quote = "\"",
+                dec = ".")

> names(Ins_single) <- c("COU","Country","FAM","Family.type","CHI","Number.of.children",
+                        "ER1","First.earner","ER2","Second.earner","VAR","Variable",
+                        "EMP","Employment.status","YEA","Year","Unit.Code","Unit",
+                        "PowerCode.Code","PowerCode","Reference.Period.Code","Reference.Period",
+                        "Value","Flag.Codes","Flags")

> Ins_married<-read.csv("TaxBen_OECD_married67.csv", header = TRUE, sep = ",", quote = "\"",
+                      dec = ".")

> names(Ins_married) <- c("COU","Country","FAM","Family.type","CHI","Number.of.children",
+                         "ER1","First.earner","ER2","Second.earner","VAR","Variable",
+                         "EMP","Employment.status","YEA","Year","Unit.Code","Unit",
+                         "PowerCode.Code", "PowerCode","Reference.Period.Code",
+                         "Reference.Period","Value","Flag.Codes","Flags" )

> ##########################
> #Extract indicators from data file for all countries
> ##########################
> 
> #single
> single<-data.frame(Ins_single$Country[Ins_single$Employment.status=="Employed"&
+                                              Ins_single$Variable=="Gross Income"],
+   Ins_single$First.earner[Ins_single$Employment.status=="Employed"&
+                                                 Ins_single$Variable=="Gross Income"],
+   Ins_single$Year[Ins_single$Employment.status=="Employed"&
+                 Ins_single$Variable=="Gross Income"],
+   Ins_single$Value[Ins_single$Employment.status=="Employed"&
+                 Ins_single$Variable=="Gross Income"],
+   Ins_single$Value[Ins_single$Employment.status=="Employed"&
+                 Ins_single$Variable=="Net Income"],
+   Ins_single$Value[Ins_single$Employment.status=="Employed"&
+                 Ins_single$Variable=="Income Tax"],
+   Ins_single$Value[Ins_single$Employment.status=="Unemployed"&
+                 Ins_single$Variable=="Net Income"])

> names(single) <- c("Country","AW","Year","Gross","Net","Tax","Unemployment")

> single$AW<-as.numeric(gsub("% of AW", "", single$AW))

> #married
> married<-data.frame(Ins_married$Country[Ins_married$Employment.status=="Employed"&
+                                                      Ins_married$Variable=="Gross Income"],
+                     Ins_married$First.earner[Ins_married$Employment.status=="Employed"&
+                                                Ins_married$Variable=="Gross Income"],
+                            Ins_married$Year[Ins_married$Employment.status=="Employed"&
+                                              Ins_married$Variable=="Gross Income"],
+                            Ins_married$Value[Ins_married$Employment.status=="Employed"&
+                                               Ins_married$Variable=="Gross Income"],
+                            Ins_married$Value[Ins_married$Employment.status=="Employed"&
+                                               Ins_married$Variable=="Net Income"],
+                            Ins_married$Value[Ins_married$Employment.status=="Employed"&
+                                               Ins_married$Variable=="Income Tax"],
+                            Ins_married$Value[Ins_married$Employment.status=="Unemployed"&
+                                               Ins_married$Variable=="Net Income"])

> names(married) <- c("Country","AW","Year","Gross","Net","Tax","Unemployment")

> married$AW<-as.numeric(gsub("% of AW", "", married$AW))

> #Remove full data file
> 
> rm(Ins_married,Ins_single)

> #Replacement Rate
> 
> single$RR<-single$Unemployment/single$Net

> married$RR<-married$Unemployment/married$Net

> #Check
> (married[married$Country=="Finland"&married$AW==148&married$Year==2014,])
     Country  AW Year Gross   Net   Tax Unemployment        RR
9464 Finland 148 2014 91814 64646 24963        51302 0.7935835

> #Plot
> ggplot(married[married$Country=="Spain"&married$AW>=50&married$Year==2014,],
+        aes(x = AW)) +
+   geom_line(aes(y = Net/Gross,col="Net/Gross"))+
+   geom_line(aes(y = Tax/Gross,col="Tax/Gross"))+
+   geom_line(aes(y = Unemployment/Gross,col="Unemployment/Gross"))+
+   scale_colour_manual("", 
+                       breaks = c("Net/Gross", "Tax/Gross", "Unemployment/Gross"),
+                       values = c("Net/Gross"="red", "Tax/Gross"="green","Unemployment/Gross"="blue"))+
+   ggtitle("Austria 2014")+
+   ylab("Proportion")+xlab("% of AW")+
+   theme_minimal()+
+   labs(caption="Source: OECD")+
+   theme(axis.text=element_text(size=14),axis.title=element_text(size=16),
+         legend.title=element_text(size=14) , legend.text=element_text(size=14))

> single%>%
+   group_by(Country,AW)%>%
+   filter(AW>=50&AW<=200)%>%
+   summarize(meanRR=mean(RR),
+             meanNet=mean(Net),
+             meanGross=mean(Gross),
+             meanTax=mean(Tax),
+             meanUnemployment=mean(Unemployment))%>%
+   ggplot(aes(x=AW))+
+   geom_line(aes(y = (meanNet/meanGross)*100,
+                 col="Net/Gross"))+
+   geom_line(aes(y = (meanUnemployment/meanGross)*100,
+                 col="Unemployment/Gross"))+
+   xlab("Average wage (in %)") +  
+   ylab ("Share of gross income (in %)")+ 
+   coord_cartesian(xlim=c(50,200), ylim=c(0,100))+
+   scale_x_continuous(expand = c(0, 0)) + 
+   scale_y_continuous(expand = c(0, 0)) +
+   theme_bw()+
+   theme(panel.border=element_blank(),
+         legend.position="bottom",
+         legend.text = element_text(size = 14),
+         legend.title = element_blank(),
+         axis.line=element_line(),
+         axis.text=element_text(size=8),
+         axis.title=element_text(size=14),
+         strip.background =element_rect(fill=F,colour = "white"))+
+   scale_color_manual(breaks = c("Net/Gross", "Unemployment/Gross"),
+                      labels = c("Net income","Replacement rate"),
+                      values=c("grey20", "grey70"))+
+   facet_wrap(~factor(Country), nrow = 5)+ 
+   theme(panel.spacing.x=unit(1, "lines"),
+         panel.spacing.y=unit(0,"lines"),
+         plot.margin = unit(c(0,0.3,0,0.3),"cm"))

> ##########################
> #Calculation Benefit Progressivity
> ##########################
> 
> #Import data
> load("DataFile_01_Income.Rda")

> #Calculate area under curve using trpezoidal rule
> AUC<-function(x,y){
+   sum(diff(x)*rollmean(y,2))
+ }

> #Progressive taxes are monotonically increasing in income, 
> #benefits can be more or less progressive or regressive for different income categories.
> #While tax function describes slope of income taxes very well,
> #fares much less good in describing benefits.
> #Set into relation area under curve of guaranteed benefits and equalized benefits for
> #lowest 25% and highest 25%.
> 
> 
> 
> #Benefit concentration indicator function
> prog<-function(x,y){
+ position_low<-y$AW[(x&y$AW>=50)&(x&y$AW<=75)]
+ rate_low<-y$RR[(x&y$AW>=50)&(x&y$AW<=75)]
+ 
+ #Area under Lorenz Curve
+ A<-AUC(position_low,rate_low)
+ 
+ #Area under Perfect Equality Line
+ B<-AUC(position_low,rep(mean(y$RR[(x&y$AW>=50)&(x&y$AW<=200)]),
+                         length(rate_low)))
+ 
+ #Area under Perfect Equality-Lorenz Curve
+ diff_low<-(B-A)/B
+ 
+ 
+ ###
+ position_high<-y$AW[(x&y$AW>=175)&(x&y$AW<=200)]
+ rate_high<-y$RR[(x&y$AW>=175)&(x&y$AW<=200)]
+ 
+ #Area under Lorenz Curve
+ A<-AUC(position_high,rate_high)
+ 
+ #Area under Perfect Equality Line
+ B<-AUC(position_high,rep(mean(y$RR[(x&y$AW>=50)&(x&y$AW<=200)]),
+                         length(rate_high)))
+ 
+ #Area under Perfect Equality-Lorenz Curve
+ diff_high<-(B-A)/B
+ 
+ result<-(diff_high-diff_low)
+ return(result) 
+ }

> ##########################
> #Generate data
> ##########################
> #Loop through each country and each year
> 
> #Round 8 (2016)
> #Round 7 (2014)
> #Round 6 (2012)
> #Round 5 (2010)
> #Round 4 (2008)
> #Round 3 (2006)
> #Round 2 (2004)
> #Round 1 (2002)
> 
> 
> #all rounds
> #chldhhe: Children in household
> #1:Yes
> #2:No
> 
> #round 1,2: 
> #marital: Legal marital status
> #1:Married
> #5:Never married
> 
> #round 3,4:
> #maritala: Legal marital status
> #1:Married
> #9:Never married and never in civil partnership
> 
> 
> #Country loop
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> ##########################
> #Austria
> ##########################
> 
> country="AT"

> country_="Austria"

> #round 1:
> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.426110670655207 
              503 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.319485199764966 
              304 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.469228377753297 
              666 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.324163972576696 
              257 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.459397425186124 
              680 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.328645693419074 
              293 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])
< table of extent 0 >

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])
< table of extent 0 >

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])
< table of extent 0 >

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])
< table of extent 0 >

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])
< table of extent 0 >

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])
< table of extent 0 >

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.46490980284364 
             437 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.327130632156737 
              259 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> ##########################
> #Belgium
> ##########################
> 
> country="BE"

> country_="Belgium"

> #round 1:
> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.826041321397402 
              375 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.457442720379979 
              300 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.820090986753403 
              374 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.444384327661822 
              335 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.809851774213461 
              338 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.439960806928255 
              314 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.818392535996266 
              368 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.441752020775813 
              258 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.784293083637541 
              406 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.436810851725042 
              310 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.778741098761123 
              451 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.434909592092592 
              311 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.792114428115603 
              418 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.439628720952299 
              292 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> ##########################
> #Switzerland
> ##########################
> 
> country="CH"

> country_="Switzerland"

> #round 1:
> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.339504411330997 
              482 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.206324217144385 
              271 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.371484095761436 
              540 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.220609662452811 
              393 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.375066358433386 
              376 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.235918889210148 
              355 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.255176815500678 
              438 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.165397668802137 
              335 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.273318644162361 
              387 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.179013686031065 
              265 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.286605559537416 
              417 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.205468679511468 
              241 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.26418544994254 
             401 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.190826179945733 
              250 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> ##########################
> #Germany
> ##########################
> 
> country="DE"

> country_="Germany"

> #round 1:
> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.0332437989924324 
               653 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.0977889130519479 
               587 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.0206557726251879 
               683 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.0942624926323371 
               593 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.107808617071999 
              644 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.144065969235864 
              604 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.115693194107509 
              583 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.156934510750305 
              596 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.10572910653991 
             749 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.139639321319461 
              692 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.0872141845378517 
               676 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.144983956300265 
              683 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.074956368475372 
              671 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.142299706898442 
              729 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> ##########################
> #Denmark
> ##########################
> 
> country="DK"

> country_="Denmark"

> #round1:
> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.770215956305913 
              330 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.462939294375677 
              372 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.774971208547416 
              335 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.473453551318119 
              351 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.776932527936681 
              262 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.474505156999877 
              400 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.780946977434486 
                4 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.47235653421886 
             376 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.845041690299978 
              353 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.508019507551414 
              392 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.836405637246931 
              406 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.504045466884846 
              410 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.841944804715319 
              355 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.501514206626063 
              362 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> ##########################
> #Spain
> ##########################
> 
> country="ES"

> country_="Spain"

> #round 1:
> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.764715230218165 
              436 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.367428485936957 
              236 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.756477458488132 
              487 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.366514367855673 
              203 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.779716622387236 
              539 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.376553520142638 
              234 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.778276279654208 
              681 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.359296657472992 
              392 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.838472886936699 
              566 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.399366814111707 
              240 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.87423417823599 
             524 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.412214610628619 
              272 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.910626602077254 
              517 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.427364414047819 
              286 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> 
> ##########################
> #Finland
> ##########################
> 
> country="FI"

> country_="Finland"

> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.593778581242782 
              450 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.290575683112957 
              451 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.579000740992513 
              512 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.295549296215527 
              432 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.567815749070934 
              472 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.301959467676777 
              501 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.543208613289201 
              557 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.306548707231412 
              457 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])
< table of extent 0 >

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])
< table of extent 0 >

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.46773038600869 
             517 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.268073943325632 
              484 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.27393015638854 
             519 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.183030967587514 
              489 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> 
> ##########################
> #France
> ##########################
> 
> country="FR"

> country_="France"

> #round 1
> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])
< table of extent 0 >

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])
< table of extent 0 >

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])
< table of extent 0 >

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])
< table of extent 0 >

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.0717900187646878 
               362 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.135362515864277 
              417 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.0412804582195907 
               442 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.119680261393679 
              440 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.0354413759886555 
               342 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.115239157672474 
              358 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.0464700407312174 
               352 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.106065992327504 
              450 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.0527472872433751 
               378 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.0986433829959835 
               407 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> 
> ##########################
> #United Kingdom
> ##########################
> 
> country="GB"

> country_="United Kingdom"

> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

1.03236496350757 
             426 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.558918614918688 
              421 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

1.03592594590594 
             363 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.567178607645454 
              296 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

1.03666065123764 
             463 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.568158811977402 
              436 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

1.03955783547858 
             453 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.563855541681566 
              442 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

1.04027182250852 
             479 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.563253704656559 
              465 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

1.00920484471819 
             444 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.561411010772555 
              511 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.991050360555029 
              395 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.525962015844378 
              470 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> ##########################
> #Ireland
> ##########################
> 
> country="IE"

> country_="Ireland"

> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.88752855716751 
             514 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.525603347227111 
              212 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.876199039925273 
              598 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.501467085657989 
              309 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.86827362943361 
             468 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.486764557861115 
              179 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.867318695386237 
              461 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.484650741470389 
              230 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.824981038114348 
              811 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.459444490568469 
              376 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.83741270726398 
             696 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.471948506633566 
              395 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.843996556895711 
              600 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.478331356321102 
              362 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> 
> ##########################
> #Italy
> ##########################
> 
> country="IT"

> country_="Italy"

> #round1:
> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.290667242913421 
              281 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.334433469667105 
              314 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.241781403922519 
              454 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.323044227274156 
              140 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])
< table of extent 0 >

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])
< table of extent 0 >

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])
< table of extent 0 >

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])
< table of extent 0 >

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])
< table of extent 0 >

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])
< table of extent 0 >

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.717830729049783 
              268 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.428054562912235 
              111 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])
< table of extent 0 >

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])
< table of extent 0 >

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> ##########################
> #Netherlands
> ##########################
> 
> country="NL"

> country_="Netherlands"

> #round 1:
> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.47562335067294 
             505 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.303569947520633 
              439 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.581860699879276 
              421 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.316152569410477 
              381 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.601009925006877 
              412 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.289265950256762 
              286 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.527980198391045 
              369 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.282435669693386 
              279 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.515715141187939 
              365 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.264189986273332 
              324 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.500411812668168 
              414 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.259982038221967 
              378 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.468157571506979 
              407 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.249087003883337 
              382 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> ##########################
> #Norway
> ##########################
> 
> country="NO"

> country_="Norway"

> #round 1:
> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.527474246298402 
              443 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.358154208512553 
              423 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.498605038339526 
              394 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.352412676324801 
              393 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.553605300482528 
              394 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.384433971301362 
              361 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.541716929751155 
              362 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.380698723545746 
              333 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.529543093952226 
              385 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.376567232345902 
              332 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.521336599615102 
              397 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.372745167095905 
              348 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.522152198627164 
              384 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.373948720977712 
              283 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> 
> ##########################
> #Portugal
> ##########################
> 
> country="PT"

> country_="Portugal"

> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.0606852657938841 
               245 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.124102420441504 
              417 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.0416072752228198 
               379 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.111938512832374 
              359 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.0981084621674471 
               376 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.147205191632238 
              690 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.0543558578872831 
               414 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.127499068707798 
              543 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.0534256983655877 
               393 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.137526822781204 
              582 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.243301509316607 
              441 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.223505536510594 
              496 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.192419078599213 
              243 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.189298294833642 
              273 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> table(single$Country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          2613           2613           2613           2613           2613           2613 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
          2613           2613           2613           2613           2613           2613 
        Sweden    Switzerland United Kingdom 
          2613           2613           2613 

> #Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands         Norway 
> #Portugal Spain Sweden Switzerland United Kingdom 
> 
> 
> 
> ##########################
> #Sweden
> ##########################
> 
> country="SE"

> country_="Sweden"

> round=1

> x<-(single$Country==country_&single$Year==2002)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.673587766329017 
              529 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.40238907007461 
             438 

> #round 2: 
> round=2

> x<-(single$Country==country_&single$Year==2004)

> #single
> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Never married"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Never married"&
+                            data$chldhhe=="No"])

0.736517197771552 
              506 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$marital=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$marital=="Married"&
+                            data$chldhhe=="Yes"])

0.42650457020217 
             380 

> #round 3: 
> round=3

> x<-(single$Country==country_&single$Year==2006)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.772529092689517 
              486 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.439243932192229 
              401 

> #round 4: 
> round=4

> x<-(single$Country==country_&single$Year==2008)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Never married and never in civil partnership"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Never married and never in civil partnership"&
+                            data$chldhhe=="No"])

0.872137977919713 
              437 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritala=="Married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritala=="Married"&
+                            data$chldhhe=="Yes"])

0.474939869123224 
              382 

> #round 5:
> round=5

> x<-(single$Country==country_&single$Year==2010)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.902163619005337 
              381 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.487268922206789 
              348 

> #round 6:
> round=6

> x<-(single$Country==country_&single$Year==2012)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.918363293533958 
              473 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.491852226830388 
              408 

> #round 7:
> round=7

> x<-(single$Country==country_&single$Year==2014)

> progressivity<-prog(x=x,y=single)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                      data$chldhhe=="No"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.941596645666018 
              453 

> #married
> progressivity<-prog(x=x,y=married)

> data$Progressivity[data$cntry==country&data$essround==round&
+                      data$maritalb=="Legally married"&
+                      data$chldhhe=="Yes"]<-progressivity

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.503050182537986 
              397 

> ##########################
> 
> 
> 
> ##########################
> #Check
> ##########################
> 
> table(data$Progressivity[data$cntry==country&data$essround==7&
+                            data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                            data$chldhhe=="No"])

0.941596645666018 
              453 

> table(data$Progressivity[data$cntry==country&data$essround==round&
+                            data$maritalb=="Legally married"&
+                            data$chldhhe=="Yes"])

0.503050182537986 
              397 

> group_by(data, 
+          group = cntry) %>%
+   summarise(meanProg = mean(Progressivity,na.rm=T))
# A tibble: 15 × 2
   group meanProg
   <chr>    <dbl>
 1 AT      0.413 
 2 BE      0.645 
 3 CH      0.267 
 4 DE      0.104 
 5 DK      0.627 
 6 ES      0.673 
 7 FI      0.392 
 8 FR      0.0838
 9 GB      0.792 
10 IE      0.731 
11 IT      0.371 
12 NL      0.412 
13 NO      0.453 
14 PT      0.132 
15 SE      0.657 

> names(data)[names(data)=="Progressivity"] <- "benefitsFamType"

> group_by(data, 
+          group = cntry) %>%
+   summarise(meanProg = mean(benefitsFamType,na.rm=T))
# A tibble: 15 × 2
   group meanProg
   <chr>    <dbl>
 1 AT      0.413 
 2 BE      0.645 
 3 CH      0.267 
 4 DE      0.104 
 5 DK      0.627 
 6 ES      0.673 
 7 FI      0.392 
 8 FR      0.0838
 9 GB      0.792 
10 IE      0.731 
11 IT      0.371 
12 NL      0.412 
13 NO      0.453 
14 PT      0.132 
15 SE      0.657 

> table(data$benefitsFamType[data$cntry=="FI"])

0.183030967587514 0.268073943325632  0.27393015638854 0.290575683112957 0.295549296215527 
              489               484               519               451               432 
0.301959467676777 0.306548707231412  0.46773038600869 0.543208613289201 0.567815749070934 
              501               457               517               557               472 
0.579000740992513 0.593778581242782 
              512               450 

> ##########################
> 
> 
> 
> ##########################
> #Generate averages
> ##########################
> 
> #generate data frame
> df<-data.frame(table(single$Country,single$Year))

> colnames(df)[1:2] <- c("country","year")

> df$country[3]
[1] Denmark
15 Levels: Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands ... United Kingdom

> for(i in 1:15){
+   x<-(single$Country==df$country[i])
+   #single
+   progressivity<-prog(x=x,y=single)
+   df$allRepl_Single[df$country==df$country[i]]<-progressivity
+   
+   #married
+   progressivity<-prog(x=x,y=married)
+   df$allRepl_Married[df$country==df$country[i]]<-progressivity
+ }

> for(j in 2002:2014){
+   for(i in 1:15) {
+     x<-(single$Country==df$country[i]&single$Year==single$Year[j])
+     #single
+     progressivity<-prog(x,y=single)
+     df$repl_Single[df$country==df$country[i]&df$year==single$Year[j]]<-progressivity
+     
+     #married
+     progressivity<-prog(x=x,y=married)
+     df$repl_Married[df$country==df$country[i]&df$year==single$Year[j]]<-progressivity
+   }
+ }

> df$country
  [1] Austria        Belgium        Denmark        Finland        France         Germany       
  [7] Ireland        Italy          Netherlands    Norway         Portugal       Spain         
 [13] Sweden         Switzerland    United Kingdom Austria        Belgium        Denmark       
 [19] Finland        France         Germany        Ireland        Italy          Netherlands   
 [25] Norway         Portugal       Spain          Sweden         Switzerland    United Kingdom
 [31] Austria        Belgium        Denmark        Finland        France         Germany       
 [37] Ireland        Italy          Netherlands    Norway         Portugal       Spain         
 [43] Sweden         Switzerland    United Kingdom Austria        Belgium        Denmark       
 [49] Finland        France         Germany        Ireland        Italy          Netherlands   
 [55] Norway         Portugal       Spain          Sweden         Switzerland    United Kingdom
 [61] Austria        Belgium        Denmark        Finland        France         Germany       
 [67] Ireland        Italy          Netherlands    Norway         Portugal       Spain         
 [73] Sweden         Switzerland    United Kingdom Austria        Belgium        Denmark       
 [79] Finland        France         Germany        Ireland        Italy          Netherlands   
 [85] Norway         Portugal       Spain          Sweden         Switzerland    United Kingdom
 [91] Austria        Belgium        Denmark        Finland        France         Germany       
 [97] Ireland        Italy          Netherlands    Norway         Portugal       Spain         
[103] Sweden         Switzerland    United Kingdom Austria        Belgium        Denmark       
[109] Finland        France         Germany        Ireland        Italy          Netherlands   
[115] Norway         Portugal       Spain          Sweden         Switzerland    United Kingdom
[121] Austria        Belgium        Denmark        Finland        France         Germany       
[127] Ireland        Italy          Netherlands    Norway         Portugal       Spain         
[133] Sweden         Switzerland    United Kingdom Austria        Belgium        Denmark       
[139] Finland        France         Germany        Ireland        Italy          Netherlands   
[145] Norway         Portugal       Spain          Sweden         Switzerland    United Kingdom
[151] Austria        Belgium        Denmark        Finland        France         Germany       
[157] Ireland        Italy          Netherlands    Norway         Portugal       Spain         
[163] Sweden         Switzerland    United Kingdom Austria        Belgium        Denmark       
[169] Finland        France         Germany        Ireland        Italy          Netherlands   
[175] Norway         Portugal       Spain          Sweden         Switzerland    United Kingdom
[181] Austria        Belgium        Denmark        Finland        France         Germany       
[187] Ireland        Italy          Netherlands    Norway         Portugal       Spain         
[193] Sweden         Switzerland    United Kingdom
15 Levels: Austria Belgium Denmark Finland France Germany Ireland Italy Netherlands ... United Kingdom

> df$cntry<-c("AT","BE","DK","FI","FR","DE","IE","IT","NL","NO","PT","ES","SE","CH","GB")

> df<-within(df, rm(country))

> df<-within(df, rm(Freq))

> df$repl_Mean<-(df$repl_Married+df$repl_Single)/2

> df$allRepl_Mean<-(df$allRepl_Single+df$allRepl_Married)/2

> df %>%
+   group_by(cntry) %>%                            
+   summarize(mean = mean(allRepl_Mean))
# A tibble: 15 × 2
   cntry   mean
   <chr>  <dbl>
 1 AT    0.385 
 2 BE    0.640 
 3 CH    0.250 
 4 DE    0.0861
 5 DK    0.647 
 6 ES    0.609 
 7 FI    0.368 
 8 FR    0.0932
 9 GB    0.777 
10 IE    0.661 
11 IT    0.450 
12 NL    0.374 
13 NO    0.446 
14 PT    0.138 
15 SE    0.622 

> ##########################
> 
> 
> #combied dot plot
> 
> df<-reshape(as.data.frame(df), varying=c("repl_Single","repl_Married","repl_Mean",
+                                          "allRepl_Single","allRepl_Married",
+                                          "allRepl_Mean"), 
+             idvar = c("cntry","year"), 
+             direction ="long", sep = "_")

> #Match with data
> 
> data$meanProg[data$cntry=="AT"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="AT"])

> data$meanProg[data$cntry=="BE"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="BE"])

> data$meanProg[data$cntry=="CH"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="CH"])

> data$meanProg[data$cntry=="DE"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="DE"])

> data$meanProg[data$cntry=="DK"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="DK"])

> data$meanProg[data$cntry=="ES"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="ES"])

> data$meanProg[data$cntry=="FI"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="FI"])

> data$meanProg[data$cntry=="FR"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="FR"])

> data$meanProg[data$cntry=="GB"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="GB"])

> data$meanProg[data$cntry=="IE"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="IE"])

> data$meanProg[data$cntry=="IT"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="IT"])

> data$meanProg[data$cntry=="NL"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="NL"])

> data$meanProg[data$cntry=="NO"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="NO"])

> data$meanProg[data$cntry=="PT"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="PT"])

> data$meanProg[data$cntry=="SE"]<-mean(df$allRepl[df$time=="Mean"&df$cntry=="SE"])

> data$Prog[data$cntry=="AT"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="AT"&df$year==2002]

> data$Prog[data$cntry=="AT"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="AT"&df$year==2004]

> data$Prog[data$cntry=="AT"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="AT"&df$year==2006]

> data$Prog[data$cntry=="AT"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="AT"&df$year==2008]

> data$Prog[data$cntry=="AT"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="AT"&df$year==2010]

> data$Prog[data$cntry=="AT"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="AT"&df$year==2012]

> data$Prog[data$cntry=="AT"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="AT"&df$year==2014]

> data$Prog[data$cntry=="BE"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="BE"&df$year==2002]

> data$Prog[data$cntry=="BE"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="BE"&df$year==2004]

> data$Prog[data$cntry=="BE"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="BE"&df$year==2006]

> data$Prog[data$cntry=="BE"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="BE"&df$year==2008]

> data$Prog[data$cntry=="BE"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="BE"&df$year==2010]

> data$Prog[data$cntry=="BE"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="BE"&df$year==2012]

> data$Prog[data$cntry=="BE"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="BE"&df$year==2014]

> data$Prog[data$cntry=="CH"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="CH"&df$year==2002]

> data$Prog[data$cntry=="CH"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="CH"&df$year==2004]

> data$Prog[data$cntry=="CH"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="CH"&df$year==2006]

> data$Prog[data$cntry=="CH"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="CH"&df$year==2008]

> data$Prog[data$cntry=="CH"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="CH"&df$year==2010]

> data$Prog[data$cntry=="CH"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="CH"&df$year==2012]

> data$Prog[data$cntry=="CH"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="CH"&df$year==2014]

> data$Prog[data$cntry=="DE"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="DE"&df$year==2002]

> data$Prog[data$cntry=="DE"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="DE"&df$year==2004]

> data$Prog[data$cntry=="DE"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="DE"&df$year==2006]

> data$Prog[data$cntry=="DE"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="DE"&df$year==2008]

> data$Prog[data$cntry=="DE"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="DE"&df$year==2010]

> data$Prog[data$cntry=="DE"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="DE"&df$year==2012]

> data$Prog[data$cntry=="DE"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="DE"&df$year==2014]

> data$Prog[data$cntry=="DK"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="DK"&df$year==2002]

> data$Prog[data$cntry=="DK"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="DK"&df$year==2004]

> data$Prog[data$cntry=="DK"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="DK"&df$year==2006]

> data$Prog[data$cntry=="DK"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="DK"&df$year==2008]

> data$Prog[data$cntry=="DK"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="DK"&df$year==2010]

> data$Prog[data$cntry=="DK"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="DK"&df$year==2012]

> data$Prog[data$cntry=="DK"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="DK"&df$year==2014]

> data$Prog[data$cntry=="ES"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="ES"&df$year==2002]

> data$Prog[data$cntry=="ES"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="ES"&df$year==2004]

> data$Prog[data$cntry=="ES"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="ES"&df$year==2006]

> data$Prog[data$cntry=="ES"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="ES"&df$year==2008]

> data$Prog[data$cntry=="ES"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="ES"&df$year==2010]

> data$Prog[data$cntry=="ES"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="ES"&df$year==2012]

> data$Prog[data$cntry=="ES"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="ES"&df$year==2014]

> data$Prog[data$cntry=="FI"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="FI"&df$year==2002]

> data$Prog[data$cntry=="FI"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="FI"&df$year==2004]

> data$Prog[data$cntry=="FI"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="FI"&df$year==2006]

> data$Prog[data$cntry=="FI"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="FI"&df$year==2008]

> data$Prog[data$cntry=="FI"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="FI"&df$year==2010]

> data$Prog[data$cntry=="FI"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="FI"&df$year==2012]

> data$Prog[data$cntry=="FI"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="FI"&df$year==2014]

> data$Prog[data$cntry=="FR"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="FR"&df$year==2002]

> data$Prog[data$cntry=="FR"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="FR"&df$year==2004]

> data$Prog[data$cntry=="FR"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="FR"&df$year==2006]

> data$Prog[data$cntry=="FR"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="FR"&df$year==2008]

> data$Prog[data$cntry=="FR"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="FR"&df$year==2010]

> data$Prog[data$cntry=="FR"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="FR"&df$year==2012]

> data$Prog[data$cntry=="FR"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="FR"&df$year==2014]

> data$Prog[data$cntry=="GB"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="GB"&df$year==2002]

> data$Prog[data$cntry=="GB"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="GB"&df$year==2004]

> data$Prog[data$cntry=="GB"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="GB"&df$year==2006]

> data$Prog[data$cntry=="GB"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="GB"&df$year==2008]

> data$Prog[data$cntry=="GB"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="GB"&df$year==2010]

> data$Prog[data$cntry=="GB"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="GB"&df$year==2012]

> data$Prog[data$cntry=="GB"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="GB"&df$year==2014]

> data$Prog[data$cntry=="IE"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="IE"&df$year==2002]

> data$Prog[data$cntry=="IE"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="IE"&df$year==2004]

> data$Prog[data$cntry=="IE"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="IE"&df$year==2006]

> data$Prog[data$cntry=="IE"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="IE"&df$year==2008]

> data$Prog[data$cntry=="IE"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="IE"&df$year==2010]

> data$Prog[data$cntry=="IE"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="IE"&df$year==2012]

> data$Prog[data$cntry=="IE"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="IE"&df$year==2014]

> data$Prog[data$cntry=="IT"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="IT"&df$year==2002]

> data$Prog[data$cntry=="IT"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="IT"&df$year==2004]

> data$Prog[data$cntry=="IT"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="IT"&df$year==2006]

> data$Prog[data$cntry=="IT"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="IT"&df$year==2008]

> data$Prog[data$cntry=="IT"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="IT"&df$year==2010]

> data$Prog[data$cntry=="IT"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="IT"&df$year==2012]

> data$Prog[data$cntry=="IT"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="IT"&df$year==2014]

> data$Prog[data$cntry=="NL"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="NL"&df$year==2002]

> data$Prog[data$cntry=="NL"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="NL"&df$year==2004]

> data$Prog[data$cntry=="NL"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="NL"&df$year==2006]

> data$Prog[data$cntry=="NL"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="NL"&df$year==2008]

> data$Prog[data$cntry=="NL"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="NL"&df$year==2010]

> data$Prog[data$cntry=="NL"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="NL"&df$year==2012]

> data$Prog[data$cntry=="NL"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="NL"&df$year==2014]

> data$Prog[data$cntry=="NO"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="NO"&df$year==2002]

> data$Prog[data$cntry=="NO"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="NO"&df$year==2004]

> data$Prog[data$cntry=="NO"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="NO"&df$year==2006]

> data$Prog[data$cntry=="NO"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="NO"&df$year==2008]

> data$Prog[data$cntry=="NO"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="NO"&df$year==2010]

> data$Prog[data$cntry=="NO"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="NO"&df$year==2012]

> data$Prog[data$cntry=="NO"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="NO"&df$year==2014]

> data$Prog[data$cntry=="PT"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="PT"&df$year==2002]

> data$Prog[data$cntry=="PT"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="PT"&df$year==2004]

> data$Prog[data$cntry=="PT"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="PT"&df$year==2006]

> data$Prog[data$cntry=="PT"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="PT"&df$year==2008]

> data$Prog[data$cntry=="PT"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="PT"&df$year==2010]

> data$Prog[data$cntry=="PT"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="PT"&df$year==2012]

> data$Prog[data$cntry=="PT"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="PT"&df$year==2014]

> data$Prog[data$cntry=="SE"&data$essround==1]<-
+   df$repl[df$time=="Mean"&df$cntry=="SE"&df$year==2002]

> data$Prog[data$cntry=="SE"&data$essround==2]<-
+   df$repl[df$time=="Mean"&df$cntry=="SE"&df$year==2004]

> data$Prog[data$cntry=="SE"&data$essround==3]<-
+   df$repl[df$time=="Mean"&df$cntry=="SE"&df$year==2006]

> data$Prog[data$cntry=="SE"&data$essround==4]<-
+   df$repl[df$time=="Mean"&df$cntry=="SE"&df$year==2008]

> data$Prog[data$cntry=="SE"&data$essround==5]<-
+   df$repl[df$time=="Mean"&df$cntry=="SE"&df$year==2010]

> data$Prog[data$cntry=="SE"&data$essround==6]<-
+   df$repl[df$time=="Mean"&df$cntry=="SE"&df$year==2012]

> data$Prog[data$cntry=="SE"&data$essround==7]<-
+   df$repl[df$time=="Mean"&df$cntry=="SE"&df$year==2014]

> table(df$cntry)

AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE 
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 

> table(data$Prog[data$cntry=="SE"&data$essround==5])

0.694716270606063 
             1497 

> table(data$meanProg[data$cntry=="SE"&data$essround==2])

0.622170442816205 
             1948 

> names(data)[names(data)=="Prog"] <- "benefitsAvgYear"

> names(data)[names(data)=="meanProg"] <- "benefitsAvg"

> ##########################
> 
> 
> ##########################
> #Save data
> ##########################
> 
> #Combine ESS with benefit concentration indicator
> save(data,file="DataFile_02_TaxBenefit.Rda")

> #Beneift concentration indicator as separate file
> save(df,file="Benefits.Rda")

> ##########################
> 
> 
> 

> ################
> #PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
> #
> #Observational Data
> #Part III: Immigration and Stability
> #
> #Verena Fetscher
> #July 2022
> ####################
> 
> 
> rm(list=ls())

> ##########################
> #Immigration
> ##########################
> 
> load("DataFile_02_TaxBenefit.Rda")

> #Import data
> #https://data.oecd.org/migration/foreign-born-population.htm
> #accessed 11-2018
> 
> immigration<-read.csv("DP_LIVE_17112017110618032.csv", header = TRUE, sep = ",", quote = "\"",
+                       dec = ".")

> names(immigration) <- c("LOCATION","INDICATOR","SUBJECT","MEASURE",
+                         "FREQUENCY","TIME","Value","Flag.Codes")

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Loop through each country
> ##########################
> 
> 
> ##########################
> #Austria
> ##########################
> 
> cntry<-"AT"

> location<-"AUT"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2008]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Belgium
> ##########################
> 
> cntry<-"BE"

> location<-"BEL"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Switzerland
> ##########################
> 
> cntry<-"CH"

> location<-"CHE"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Germany
> ##########################
> 
> cntry<-"DE"

> location<-"DEU"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Denmark
> ##########################
> 
> cntry<-"DK"

> location<-"DNK"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Spain
> ##########################
> 
> cntry<-"ES"

> location<-"ESP"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> 
> ##########################
> #Finland
> ##########################
> 
> cntry<-"FI"

> location<-"FIN"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #France
> ##########################
> 
> cntry<-"FR"

> location<-"FRA"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #GB
> ##########################
> 
> cntry<-"GB"

> location<-"GBR"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Ireland
> ##########################
> 
> cntry<-"IE"

> location<-"IRL"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Italy
> ##########################
> 
> cntry<-"IT"

> location<-"ITA"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   (immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]+
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005])/2

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Netherlands
> ##########################
> 
> cntry<-"NL"

> location<-"NLD"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Norway
> ##########################
> 
> cntry<-"NO"

> location<-"NOR"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Portugal
> ##########################
> 
> cntry<-"PT"

> location<-"PRT"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> table(immigration$LOCATION)

AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD NOR POL PRT SVK SVN SWE 
 13  13  13  13  13  13  13  13  13  13  13  11  13  13  11  13  13  13  12  13  13  12  13 

> #AUT BEL CHE CZE DEU DNK ESP EST FIN FRA GBR GRC HUN IRL ITA LUX NLD 
> #NOR POL PRT SVK SVN SWE
> 
> 
> ##########################
> #Sweden
> ##########################
> 
> cntry<-"SE"

> location<-"SWE"

> data$immigration[data$cntry==cntry&data$essround==1]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2001]

> data$immigration[data$cntry==cntry&data$essround==2]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2003]

> data$immigration[data$cntry==cntry&data$essround==3]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2005]

> data$immigration[data$cntry==cntry&data$essround==4]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2007]

> data$immigration[data$cntry==cntry&data$essround==5]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2009]

> data$immigration[data$cntry==cntry&data$essround==6]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2011]

> data$immigration[data$cntry==cntry&data$essround==7]<-
+   immigration$Value[immigration$LOCATION==location&immigration$TIME==2013]

> data%>%
+   group_by(cntry,essround)%>%
+   summarise(mean=mean(immigration,is.na=T))
# A tibble: 98 × 3
# Groups:   cntry [15]
   cntry essround  mean
   <chr> <fct>    <dbl>
 1 AT    1         13.8
 2 AT    2         14.1
 3 AT    3         14.5
 4 AT    7         16.7
 5 BE    1         10.8
 6 BE    2         11.4
 7 BE    3         12.1
 8 BE    4         13.0
 9 BE    5         13.9
10 BE    6         15.0
# … with 88 more rows
# ℹ Use `print(n = ...)` to see more rows

> ##########################
> #Notes
> ##########################
> 
> #1) Value for Italy in 2004 is average of (2002+2006)/2
> #2) Austria 2008 uses value for 2008 rather than previous year
> 
> 
> ##########################
> #Save data
> ##########################
> 
> save(data,file="DataFile_03_Immigration.Rda")

> ##########################
> 
> 
> 
> 
> ##########################
> #Income mobility
> ##########################
> 
> #http://ec.europa.eu/eurostat/web/income-and-living-conditions/data/database?p_p_id=NavTreeportletprod_WAR_NavTreeportletprod_INSTANCE_CEM7npyJJgVL&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-2&p_p_col_count=1
> #http://appsso.eurostat.ec.europa.eu/nui/show.do?dataset=ilc_di30c&lang=en
> #http://ec.europa.eu/eurostat/statistics-explained/index.php/EU_statistics_on_income_and_living_conditions_(EU-SILC)_methodology_-_distribution_of_income
> 
> #The Transitions of income within three years by decile refers to the 
> #distribution (%) of persons by the income decile class they move to in 
> #the survey year (t); shown separately for each income decile class during 
> #the last three year (t-3).
> 
> 
> #Import data
> eurostat<-read.csv("ilc_di30c_1_Data.csv", header = TRUE, sep = ",", quote = "\"",
+                    dec = ".")

> names(eurostat) <- c("TIME","GEO","UNIT","TRANS3Y","QUANTILE","Value","Flag.and.Footnotes")

> ##########################
> #Data recoding
> ##########################
> 
> #Factor to numeric
> as.numeric.factor <- function(x) {as.numeric(levels(x))[x]}

> as.character.factor <- function(x) {as.character(levels(x))[x]}

> eurostat$ValueNum<-as.numeric(eurostat$Value)

> #Extract data
> x<-eurostat[eurostat$TRANS3Y=="No change"&eurostat$QUANTILE=="Total",] %>%
+   group_by(GEO,TIME) %>%
+   summarise(mean = mean(ValueNum, na.rm=T))

> x$GEO<-as.factor(x$GEO)

> table(x$GEO)

                                         Austria 
                                              10 
                                         Belgium 
                                              10 
                                         Denmark 
                                              10 
                                         Finland 
                                              10 
                                          France 
                                              10 
Germany (until 1990 former territory of the FRG) 
                                              10 
                                         Ireland 
                                              10 
                                           Italy 
                                              10 
                                     Netherlands 
                                              10 
                                          Norway 
                                              10 
                                        Portugal 
                                              10 
                                           Spain 
                                              10 
                                          Sweden 
                                              10 
                                     Switzerland 
                                              10 
                                  United Kingdom 
                                              10 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> 
> ##########################
> #Add data to ESS
> ##########################
> 
> 
> ##########################
> #Austria
> ##########################
> 
> cntry<-"AT"

> geo<-"Austria"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

30.94 
 8713 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Belgium
> ##########################
> 
> cntry<-"BE"

> geo<-"Belgium"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

31.78 
12577 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Switzerland
> ##########################
> 
> cntry<-"CH"

> geo<-"Switzerland"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

30.26 
12335 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Germany
> ##########################
> 
> cntry<-"DE"

> geo<-"Germany (until 1990 former territory of the FRG)"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

33.2666666666667 
           20490 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Denmark
> ##########################
> 
> cntry<-"DK"

> geo<-"Denmark"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

34.06 
10836 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Spain
> ##########################
> 
> cntry<-"ES"

> geo<-"Spain"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

 30.6 
13543 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Finland
> ##########################
> 
> cntry<-"FI"

> geo<-"Finland"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

36.1555555555556 
           14275 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #France
> ##########################
> 
> cntry<-"FR"

> geo<-"France"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

35.5714285714286 
           12981 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #GB
> ##########################
> 
> cntry<-"GB"

> geo<-"United Kingdom"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

 27.6 
15667 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Ireland
> ##########################
> 
> cntry<-"IE"

> geo<-"Ireland"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

28.2333333333333 
           15490 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Italy
> ##########################
> 
> cntry<-"IT"

> geo<-"Italy"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

35.07 
 3696 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Netherlands
> ##########################
> 
> cntry<-"NL"

> geo<-"Netherlands"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

37.4444444444444 
           13505 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Norway
> ##########################
> 
> cntry<-"NO"

> geo<-"Norway"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

34.52 
11703 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Portugal
> ##########################
> 
> cntry<-"PT"

> geo<-"Portugal"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

34.43 
13718 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> #Sweden
> ##########################
> 
> cntry<-"SE"

> geo<-"Sweden"

> data$mobility[data$cntry==cntry]<-mean(x$mean[x$GEO==geo],na.rm=T)

> table(data$mobility[data$cntry==cntry])

34.13 
12839 

> data$mobility_year[data$cntry==cntry&data$essround==4]<-x$mean[x$GEO==geo&x$TIME==2008]

> data$mobility_year[data$cntry==cntry&data$essround==5]<-x$mean[x$GEO==geo&x$TIME==2010]

> data$mobility_year[data$cntry==cntry&data$essround==6]<-x$mean[x$GEO==geo&x$TIME==2012]

> data$mobility_year[data$cntry==cntry&data$essround==7]<-x$mean[x$GEO==geo&x$TIME==2014]

> ##########################
> 
> 
> ##########################
> #Check
> ##########################
> 
> group_by(data, 
+          group = cntry) %>%
+   summarise(meanMob = mean(mobility,na.rm=T))
# A tibble: 15 × 2
   group meanMob
   <chr>   <dbl>
 1 AT       30.9
 2 BE       31.8
 3 CH       30.3
 4 DE       33.3
 5 DK       34.1
 6 ES       30.6
 7 FI       36.2
 8 FR       35.6
 9 GB       27.6
10 IE       28.2
11 IT       35.1
12 NL       37.4
13 NO       34.5
14 PT       34.4
15 SE       34.1

> ##########################
> 
> 
> ##########################
> #Save data
> ##########################
> 
> save(data,file="DataFile_04_Stability.Rda")

> ##########################
> 
> 
> 

> ################
> #PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
> #
> #Observational Data
> #Part IV: Unemployment Risk
> #
> #Verena Fetscher
> #July 2022
> ####################
> 
> 
> rm(list=ls())

> ##########################
> #Load data
> ##########################
> 
> load("DataFile_04_Stability.Rda")

> ##########################
> #Unemployment risk
> ##########################
> 
> #Import data
> 
> #Calculation unemployment risk
> #Data Source Eurostat employment and unemployment
> #website http://ec.europa.eu/eurostat/web/lfs/data/database
> #Accessed 02-2017
> 
> 
> #Previous occupations of the unemployed, by sex (1 000) (lfsq_ugpis)
> #lfsa_ugpis_1_Data
> #website http://appsso.eurostat.ec.europa.eu/nui/show.do?dataset=lfsa_ugpis&lang=en 
> UE_occu<-read.csv("lfsa_ugpis_1_Data.csv", header = TRUE, sep = ",", quote = "\"",
+                   dec = ".")

> names(UE_occu) <- c("TIME","GEO","SEX","ISCO08","UNIT","Value","Flag.and.Footnotes")

> #Unemployment rates by sex, age and educational attainment level (%) (lfsq_urgaed)	 
> #lfsa_urgaed_1_Data
> #website http://appsso.eurostat.ec.europa.eu/nui/show.do?dataset=lfsq_urgaed&lang=en
> UE_rate<-read.csv("lfsa_urgaed_1_Data.csv", header = TRUE, sep = ",", quote = "\"",
+                   dec = ".")

> names(UE_rate) <- c("TIME","GEO","SEX","AGE","ISCED11","UNIT","Value","Flag.and.Footnotes")

> #Employment by sex, occupation and educational attainment level (1 000)
> #lfsa_egised_1_Data
> #http://appsso.eurostat.ec.europa.eu/nui/show.do?dataset=lfsa_egised&lang=en
> Empl<-read.csv("lfsa_egised_1_Data.csv", header = TRUE, sep = ",", quote = "\"",
+                dec = ".")

> names(Empl) <- c("TIME","GEO","SEX","ISCED11","ISCO08","UNIT","Value","Flag.and.Footnotes")

> ##########################
> #Generate occupational unemployment rates
> ##########################
> 
> #Following Rehm (2011)
> #unemployment rate of occupation j=
> #unemployed in occupation j/(unemployed in occupation j + employed in occupation j)
> 
> #Generate main occupational groups based on ISCO main groups
> table(Empl$ISCO08)

                          Armed forces occupations 
                                              9360 
                          Clerical support workers 
                                              9360 
                  Craft and related trades workers 
                                              9360 
                            Elementary occupations 
                                              9360 
                                          Managers 
                                              9360 
                                       No response 
                                              9360 
        Plant and machine operators and assemblers 
                                              9360 
                                     Professionals 
                                              9360 
                         Service and sales workers 
                                              9360 
Skilled agricultural, forestry and fishery workers 
                                              9360 
           Technicians and associate professionals 
                                              9360 
                                             Total 
                                              9360 

> #iscoco: 	ESS1, ESS2, ESS3, ESS4, ESS5: What is/was the name or title 
> #of your main job? In your main job, what kind of work do/did you do 
> #most of the time? What training or qualifications are/were needed for the job?
> 
> table(na.omit(data$iscoco))

 100 1000 1100 1110 1140 1141 1142 1143 1200 1210 1220 1221 1222 1223 1224 1225 1226 1227 1228 
 395   61   28  160   10    9   24   17   48  785  230   34  438  191  266  148  175  202   72 
1229 1230 1231 1232 1233 1234 1235 1236 1237 1239 1300 1310 1311 1312 1313 1314 1315 1316 1317 
 546  117  703  268  644  106  128  199  179  544   95  105  298  255  339 1451  654  202  400 
1318 1319 2000 2100 2110 2111 2112 2113 2114 2120 2121 2122 2130 2131 2139 2140 2141 2142 2143 
 164  678   64   35   14   30   12  104   24    2   27   31  224  757  329  104  359  300  144 
2144 2145 2146 2147 2148 2149 2200 2210 2211 2212 2213 2220 2221 2222 2223 2224 2229 2230 2300 
 170  289   76   39   78  530   22   14  126   33   84   17  658  135   69  132  141 1045  314 
2310 2320 2330 2331 2332 2340 2350 2351 2352 2359 2400 2410 2411 2412 2419 2420 2421 2422 2429 
 711 2069  207 1399  217  219   72  132   49  524   49   63  690  356 1014   57  250   59  175 
2430 2431 2432 2440 2441 2442 2443 2444 2445 2446 2450 2451 2452 2453 2454 2455 2460 2470 3000 
  15   65  137   19  170   46   38  129  205  515   28  430  231  158   22  130  138  493   26 
3100 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3130 3131 3132 3133 
  84  140  210  343  186  306  351  105   40  318  614  279  266  229   19    4  191   52   70 
3139 3140 3141 3142 3143 3144 3145 3150 3151 3152 3200 3210 3211 3212 3213 3220 3221 3222 3223 
  24   19   38   82   40   38   18   32   35  448   43   10  207   56   25   46  145   34   50 
3224 3225 3226 3227 3228 3229 3230 3231 3232 3300 3310 3320 3330 3340 3400 3410 3411 3412 3413 
  81  146  406   50  163  343   38 1947   65   58  590  599  141  528  149  246  115  382  225 
3414 3415 3416 3417 3419 3420 3421 3422 3423 3429 3430 3431 3432 3433 3434 3440 3441 3442 3443 
  64 1330  294   65  887   48   94   44  118  222  506 1719  366  759   42   77   44  147  132 
3444 3449 3450 3460 3470 3471 3472 3473 3474 3475 3480 4000 4100 4110 4111 4112 4113 4114 4115 
  42  178  203  894   59  377   25   63   21  229   58  474  298  480  134   49  148   14 1993 
4120 4121 4122 4130 4131 4132 4133 4140 4141 4142 4143 4144 4190 4200 4210 4211 4212 4213 4214 
 323 1266  584   88  970  427  358   11  227  594   27   34 2857  136  179  546  454   27    2 
4215 4220 4221 4222 4223 4290 5000 5100 5110 5111 5112 5113 5120 5121 5122 5123 5130 5131 5132 
  43  143  105  817  454    3   27   51    7  110   99   61  194  366 1584 2021  531 1583 2089 
5133 5139 5140 5141 5142 5143 5149 5160 5161 5162 5163 5169 5200 5210 5220 6000 6100 6110 6111 
1249  402   28 1064   47   27  276   33  142  396   91  337  121   15 7065    6  126   46  521 
6112 6120 6121 6122 6129 6130 6140 6141 6142 6150 6151 6152 6153 6154 7000 7100 7110 7111 7112 
 765   35  619   47   76 1420   92   83    3   34   15   51   27    5   65   31    1   72   13 
7113 7120 7121 7122 7123 7124 7129 7130 7131 7132 7133 7134 7135 7136 7137 7139 7140 7141 7143 
  46  119  316 1032  146 1008  303   20  115  127  122   77   63  592  546   90   28  635   52 
7200 7210 7211 7212 7213 7214 7215 7216 7220 7221 7222 7223 7224 7230 7231 7232 7233 7240 7241 
 121   85   56  408  225  196   21    4   11  135  325  350   62  277  962   56  494   83  604 
7242 7244 7245 7300 7310 7311 7312 7313 7320 7321 7322 7323 7324 7330 7331 7332 7340 7341 7342 
 235  126  136   30    9  152   15   76   12   49   58    2   34   18   56   36   30  161   17 
7343 7344 7345 7346 7400 7410 7411 7412 7413 7414 7415 7416 7420 7421 7422 7423 7424 7430 7431 
  35   48   58   39   49   15  349  402   38   27    5   15   25   63  436   46   11   36   27 
7432 7433 7434 7435 7436 7437 7440 7441 7442 8000 8100 8110 8111 8112 8113 8120 8121 8122 8123 
  88  507   13   52  506   93    1   21  121  122   54   12   24   21   33   20   47   61   25 
8124 8130 8131 8139 8140 8141 8142 8143 8150 8151 8152 8153 8154 8155 8159 8160 8161 8162 8163 
   9    8   39   25   36  121   20   95   70    5    3    4    1   16   34   17   49   41   35 
8170 8200 8210 8211 8212 8220 8221 8222 8223 8224 8229 8230 8231 8232 8240 8250 8251 8252 8253 
  55  124   16  282   44   42   50   13   72   14   32   10   40  159   74   13  162   23   62 
8260 8261 8262 8263 8264 8265 8266 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 
  45  117  126  350  134   10   51  119   82  159   47   26   94   36   11    5   49   15  116 
8281 8282 8283 8284 8285 8286 8287 8290 8300 8310 8311 8312 8320 8321 8322 8323 8324 8330 8331 
 211  170  124   86   49   14   17  647   21    8  148   82  127    5  794  485 1266   42  104 
8332 8333 8334 8340 9000 9100 9110 9111 9113 9120 9130 9131 9132 9133 9140 9141 9142 9150 9151 
 252  191  288   91  198  155   18  101  123    7  643 1630 3606  204    9  743   64   30  568 
9152 9153 9160 9161 9162 9200 9210 9211 9212 9213 9300 9310 9311 9312 9313 9320 9330 
 444   30   27   81  133   19  110  877   37   35   81   18   35  475  471 1323  905 

> typeof(data$iscoco)
[1] "double"

> data$occupation<-NA

> data$occupation[data$iscoco==100]<-"Armed forces occupations"

> data$occupation[data$iscoco>100&data$iscoco<2000]<-"Managers"

> data$occupation[data$iscoco>=2000&data$iscoco<3000]<-"Professionals"

> data$occupation[data$iscoco>=3000&data$iscoco<4000]<-"Technicians and associate professionals"

> data$occupation[data$iscoco>=4000&data$iscoco<5000]<-"Clerical support workers"

> data$occupation[data$iscoco>=5000&data$iscoco<6000]<-"Service and sales workers"

> data$occupation[data$iscoco>=6000&data$iscoco<7000]<-"Skilled agricultural, forestry and fishery workers"

> data$occupation[data$iscoco>=7000&data$iscoco<8000]<-"Craft and related trades workers"

> data$occupation[data$iscoco>=8000&data$iscoco<9000]<-"Plant and machine operators and assemblers"

> data$occupation[data$iscoco>=9000&data$iscoco<=9330]<-"Elementary occupations"

> length(na.omit(data$occupation))
[1] 124855

> table(data$occupation)

                          Armed forces occupations 
                                               395 
                          Clerical support workers 
                                             14265 
                  Craft and related trades workers 
                                             14472 
                            Elementary occupations 
                                             13200 
                                          Managers 
                                             10973 
        Plant and machine operators and assemblers 
                                              9148 
                                     Professionals 
                                             17813 
                         Service and sales workers 
                                             20016 
Skilled agricultural, forestry and fishery workers 
                                              3971 
           Technicians and associate professionals 
                                             20602 

> attributes(data$isco08)
$levels
  [1] "Armed forces occupations"                                    
  [2] "Commissioned armed forces officers"                          
  [3] "Commissioned armed forces officers"                          
  [4] "Non-commissioned armed forces officers"                      
  [5] "Non-commissioned armed forces officers"                      
  [6] "Armed forces occupations, other ranks"                       
  [7] "Armed forces occupations, other ranks"                       
  [8] "Managers"                                                    
  [9] "Chief executives, senior officials and legislators"          
 [10] "Legislators and senior officials"                            
 [11] "Legislators"                                                 
 [12] "Senior government officials"                                 
 [13] "Traditional chiefs and heads of village"                     
 [14] "Senior officials of special-interest organizations"          
 [15] "Managing directors and chief executives"                     
 [16] "Administrative and commercial managers"                      
 [17] "Business services and administration managers"               
 [18] "Finance managers"                                            
 [19] "Human resource managers"                                     
 [20] "Policy and planning managers"                                
 [21] "Business services and administration managers not elsewhere" 
 [22] "Sales, marketing and development managers"                   
 [23] "Sales and marketing managers"                                
 [24] "Advertising and public relations managers"                   
 [25] "Research and development managers"                           
 [26] "Production and specialised services managers"                
 [27] "Production managers in agriculture, forestry and fisheries"  
 [28] "Agricultural and forestry production managers"               
 [29] "Aquaculture and fisheries production managers"               
 [30] "Manufacturing, mining, construction, and distribution manage"
 [31] "Manufacturing managers"                                      
 [32] "Mining managers"                                             
 [33] "Construction managers"                                       
 [34] "Supply, distribution and related managers"                   
 [35] "Information and communications technology service managers"  
 [36] "Professional services managers"                              
 [37] "Child care services managers"                                
 [38] "Health services managers"                                    
 [39] "Aged care services managers"                                 
 [40] "Social welfare managers"                                     
 [41] "Education managers"                                          
 [42] "Financial and insurance services branch managers"            
 [43] "Professional services managers not elsewhere classified"     
 [44] "Hospitality, retail and other services managers"             
 [45] "Hotel and restaurant managers"                               
 [46] "Hotel managers"                                              
 [47] "Restaurant managers"                                         
 [48] "Retail and wholesale trade managers"                         
 [49] "Other services managers"                                     
 [50] "Sports, recreation and cultural centre managers"             
 [51] "Services managers not elsewhere classified"                  
 [52] "Professionals"                                               
 [53] "Science and engineering professionals"                       
 [54] "Physical and earth science professionals"                    
 [55] "Physicists and astronomers"                                  
 [56] "Meteorologists"                                              
 [57] "Chemists"                                                    
 [58] "Geologists and geophysicists"                                
 [59] "Mathematicians, actuaries and statisticians"                 
 [60] "Life science professionals"                                  
 [61] "Biologists, botanists, zoologists and related professionals" 
 [62] "Farming, forestry and fisheries advisers"                    
 [63] "Environmental protection professionals"                      
 [64] "Engineering professionals (excluding electrotechnology)"     
 [65] "Industrial and production engineers"                         
 [66] "Civil engineers"                                             
 [67] "Environmental engineers"                                     
 [68] "Mechanical engineers"                                        
 [69] "Chemical engineers"                                          
 [70] "Mining engineers, metallurgists and related professionals"   
 [71] "Engineering professionals not elsewhere classified"          
 [72] "Electrotechnology engineers"                                 
 [73] "Electrical engineers"                                        
 [74] "Electronics engineers"                                       
 [75] "Telecommunications engineers"                                
 [76] "Architects, planners, surveyors and designers"               
 [77] "Building architects"                                         
 [78] "Landscape architects"                                        
 [79] "Product and garment designers"                               
 [80] "Town and traffic planners"                                   
 [81] "Cartographers and surveyors"                                 
 [82] "Graphic and multimedia designers"                            
 [83] "Health professionals"                                        
 [84] "Medical doctors"                                             
 [85] "Generalist medical practitioners"                            
 [86] "Specialist medical practitioners"                            
 [87] "Nursing and midwifery professionals"                         
 [88] "Nursing professionals"                                       
 [89] "Midwifery professionals"                                     
 [90] "Traditional and complementary medicine professionals"        
 [91] "Paramedical practitioners"                                   
 [92] "Veterinarians"                                               
 [93] "Other health professionals"                                  
 [94] "Dentists"                                                    
 [95] "Pharmacists"                                                 
 [96] "Environmental and occupational health and hygiene profession"
 [97] "Physiotherapists"                                            
 [98] "Dieticians and nutritionists"                                
 [99] "Audiologists and speech therapists"                          
[100] "Optometrists and ophthalmic opticians"                       
[101] "Health professionals not elsewhere classified"               
[102] "Teaching professionals"                                      
[103] "University and higher education teachers"                    
[104] "Vocational education teachers"                               
[105] "Secondary education teachers"                                
[106] "Primary school and early childhood teachers"                 
[107] "Primary school teachers"                                     
[108] "Early childhood educators"                                   
[109] "Other teaching professionals"                                
[110] "Education methods specialists"                               
[111] "Special needs teachers"                                      
[112] "Other language teachers"                                     
[113] "Other music teachers"                                        
[114] "Other arts teachers"                                         
[115] "Information technology trainers"                             
[116] "Teaching professionals not elsewhere classified"             
[117] "Business and administration professionals"                   
[118] "Finance professionals"                                       
[119] "Accountants"                                                 
[120] "Financial and investment advisers"                           
[121] "Financial analysts"                                          
[122] "Administration professionals"                                
[123] "Management and organization analysts"                        
[124] "Policy administration professionals"                         
[125] "Personnel and careers professionals"                         
[126] "Training and staff development professionals"                
[127] "Sales, marketing and public relations professionals"         
[128] "Advertising and marketing professionals"                     
[129] "Public relations professionals"                              
[130] "Technical and medical sales professionals (excluding ICT)"   
[131] "Information and communications technology sales professional"
[132] "Information and communications technology professionals"     
[133] "Software and applications developers and analysts"           
[134] "Systems analysts"                                            
[135] "Software developers"                                         
[136] "Web and multimedia developers"                               
[137] "Applications programmers"                                    
[138] "Software and applications developers and analysts not elsewh"
[139] "Database and network professionals"                          
[140] "Database designers and administrators"                       
[141] "Systems administrators"                                      
[142] "Computer network professionals"                              
[143] "Database and network professionals not elsewhere classified" 
[144] "Legal, social and cultural professionals"                    
[145] "Legal professionals"                                         
[146] "Lawyers"                                                     
[147] "Judges"                                                      
[148] "Legal professionals not elsewhere classified"                
[149] "Librarians, archivists and curators"                         
[150] "Archivists and curators"                                     
[151] "Librarians and related information professionals"            
[152] "Social and religious professionals"                          
[153] "Economists"                                                  
[154] "Sociologists, anthropologists and related professionals"     
[155] "Philosophers, historians and political scientists"           
[156] "Psychologists"                                               
[157] "Social work and counselling professionals"                   
[158] "Religious professionals"                                     
[159] "Authors, journalists and linguists"                          
[160] "Authors and related writers"                                 
[161] "Journalists"                                                 
[162] "Translators, interpreters and other linguists"               
[163] "Creative and performing artists"                             
[164] "Visual artists"                                              
[165] "Musicians, singers and composers"                            
[166] "Dancers and choreographers"                                  
[167] "Film, stage and related directors and producers"             
[168] "Actors"                                                      
[169] "Announcers on radio, television and other media"             
[170] "Creative and performing artists not elsewhere classified"    
[171] "Technicians and associate professionals"                     
[172] "Science and engineering associate professionals"             
[173] "Physical and engineering science technicians"                
[174] "Chemical and physical science technicians"                   
[175] "Civil engineering technicians"                               
[176] "Electrical engineering technicians"                          
[177] "Electronics engineering technicians"                         
[178] "Mechanical engineering technicians"                          
[179] "Chemical engineering technicians"                            
[180] "Mining and metallurgical technicians"                        
[181] "Draughtspersons"                                             
[182] "Physical and engineering science technicians not elsewhere c"
[183] "Mining, manufacturing and construction supervisors"          
[184] "Mining supervisors"                                          
[185] "Manufacturing supervisors"                                   
[186] "Construction supervisors"                                    
[187] "Process control technicians"                                 
[188] "Power production plant operators"                            
[189] "Incinerator and water treatment plant operators"             
[190] "Chemical processing plant controllers"                       
[191] "Petroleum and natural gas refining plant operators"          
[192] "Metal production process controllers"                        
[193] "Process control technicians not elsewhere classified"        
[194] "Life science technicians and related associate professionals"
[195] "Life science technicians (excluding medical)"                
[196] "Agricultural technicians"                                    
[197] "Forestry technicians"                                        
[198] "Ship and aircraft controllers and technicians"               
[199] "Ships' engineers"                                            
[200] "Ships' deck officers and pilots"                             
[201] "Aircraft pilots and related associate professionals"         
[202] "Air traffic controllers"                                     
[203] "Air traffic safety electronics technicians"                  
[204] "Health associate professionals"                              
[205] "Medical and pharmaceutical technicians"                      
[206] "Medical imaging and therapeutic equipment technicians"       
[207] "Medical and pathology laboratory technicians"                
[208] "Pharmaceutical technicians and assistants"                   
[209] "Medical and dental prosthetic technicians"                   
[210] "Nursing and midwifery associate professionals"               
[211] "Nursing associate professionals"                             
[212] "Midwifery associate professionals"                           
[213] "Traditional and complementary medicine associate professiona"
[214] "Veterinary technicians and assistants"                       
[215] "Other health associate professionals"                        
[216] "Dental assistants and therapists"                            
[217] "Medical records and health information technicians"          
[218] "Community health workers"                                    
[219] "Dispensing opticians"                                        
[220] "Physiotherapy technicians and assistants"                    
[221] "Medical assistants"                                          
[222] "Environmental and occupational health inspectors and associa"
[223] "Ambulance workers"                                           
[224] "Health associate professionals not elsewhere classified"     
[225] "Business and administration associate professionals"         
[226] "Financial and mathematical associate professionals"          
[227] "Securities and finance dealers and brokers"                  
[228] "Credit and loans officers"                                   
[229] "Accounting associate professionals"                          
[230] "Statistical, mathematical and related associate professional"
[231] "Valuers and loss assessors"                                  
[232] "Sales and purchasing agents and brokers"                     
[233] "Insurance representatives"                                   
[234] "Commercial sales representatives"                            
[235] "Buyers"                                                      
[236] "Trade brokers"                                               
[237] "Business services agents"                                    
[238] "Clearing and forwarding agents"                              
[239] "Conference and event planners"                               
[240] "Employment agents and contractors"                           
[241] "Real estate agents and property managers"                    
[242] "Business services agents not elsewhere classified"           
[243] "Administrative and specialised secretaries"                  
[244] "Office supervisors"                                          
[245] "Legal secretaries"                                           
[246] "Administrative and executive secretaries"                    
[247] "Medical secretaries"                                         
[248] "Regulatory government associate professionals"               
[249] "Customs and border inspectors"                               
[250] "Government tax and excise officials"                         
[251] "Government social benefits officials"                        
[252] "Government licensing officials"                              
[253] "Police inspectors and detectives"                            
[254] "Regulatory government associate professionals not elsewhere" 
[255] "Legal, social, cultural and related associate professionals" 
[256] "Legal, social and religious associate professionals"         
[257] "Police inspectors and detectives"                            
[258] "Social work associate professionals"                         
[259] "Religious associate professionals"                           
[260] "Sports and fitness workers"                                  
[261] "Athletes and sports players"                                 
[262] "Sports coaches, instructors and officials"                   
[263] "Fitness and recreation instructors and program leaders"      
[264] "Artistic, cultural and culinary associate professionals"     
[265] "Photographers"                                               
[266] "Interior designers and decorators"                           
[267] "Gallery, museum and library technicians"                     
[268] "Chefs"                                                       
[269] "Other artistic and cultural associate professionals"         
[270] "Information and communications technicians"                  
[271] "Information and communications technology operations and use"
[272] "Information and communications technology operations technic"
[273] "Information and communications technology user support techn"
[274] "Computer network and systems technicians"                    
[275] "Web technicians"                                             
[276] "Telecommunications and broadcasting technicians"             
[277] "Broadcasting and audio-visual technicians"                   
[278] "Telecommunications engineering technicians"                  
[279] "Clerical support workers"                                    
[280] "General and keyboard clerks"                                 
[281] "General office clerks"                                       
[282] "Secretaries (general)"                                       
[283] "Keyboard operators"                                          
[284] "Typists and word processing operators"                       
[285] "Data entry clerks"                                           
[286] "Customer services clerks"                                    
[287] "Tellers, money collectors and related clerks"                
[288] "Bank tellers and related clerks"                             
[289] "Bookmakers, croupiers and related gaming workers"            
[290] "Pawnbrokers and money-lenders"                               
[291] "Debt-collectors and related workers"                         
[292] "Client information workers"                                  
[293] "Travel consultants and clerks"                               
[294] "Contact centre information clerks"                           
[295] "Telephone switchboard operators"                             
[296] "Hotel receptionists"                                         
[297] "Enquiry clerks"                                              
[298] "Receptionists (general)"                                     
[299] "Survey and market research interviewers"                     
[300] "Client information workers not elsewhere classified"         
[301] "Numerical and material recording clerks"                     
[302] "Numerical clerks"                                            
[303] "Accounting and bookkeeping clerks"                           
[304] "Statistical, finance and insurance clerks"                   
[305] "Payroll clerks"                                              
[306] "Material-recording and transport clerks"                     
[307] "Stock clerks"                                                
[308] "Production clerks"                                           
[309] "Transport clerks"                                            
[310] "Other clerical support workers"                              
[311] "Other clerical support workers"                              
[312] "Library clerks"                                              
[313] "Mail carriers and sorting clerks"                            
[314] "Coding, proof-reading and related clerks"                    
[315] "Scribes and related workers"                                 
[316] "Filing and copying clerks"                                   
[317] "Personnel clerks"                                            
[318] "Clerical support workers not elsewhere classified"           
[319] "Service and sales workers"                                   
[320] "Personal service workers"                                    
[321] "Travel attendants, conductors and guides"                    
[322] "Travel attendants and travel stewards"                       
[323] "Transport conductors"                                        
[324] "Travel guides"                                               
[325] "Cooks"                                                       
[326] "Waiters and bartenders"                                      
[327] "Waiters"                                                     
[328] "Bartenders"                                                  
[329] "Hairdressers, beauticians and related workers"               
[330] "Hairdressers"                                                
[331] "Beauticians and related workers"                             
[332] "Building and housekeeping supervisors"                       
[333] "Cleaning and housekeeping supervisors in offices, hotels and"
[334] "Domestic housekeepers"                                       
[335] "Building caretakers"                                         
[336] "Other personal services workers"                             
[337] "Astrologers, fortune-tellers and related workers"            
[338] "Companions and valets"                                       
[339] "Undertakers and embalmers"                                   
[340] "Pet groomers and animal care workers"                        
[341] "Driving instructors"                                         
[342] "Personal services workers not elsewhere classified"          
[343] "Sales workers"                                               
[344] "Street and market salespersons"                              
[345] "Stall and market salespersons"                               
[346] "Street food salespersons"                                    
[347] "Shop salespersons"                                           
[348] "Shop keepers"                                                
[349] "Shop supervisors"                                            
[350] "Shop sales assistants"                                       
[351] "Cashiers and ticket clerks"                                  
[352] "Other sales workers"                                         
[353] "Fashion and other models"                                    
[354] "Sales demonstrators"                                         
[355] "Door to door salespersons"                                   
[356] "Contact centre salespersons"                                 
[357] "Service station attendants"                                  
[358] "Food service counter attendants"                             
[359] "Sales workers not elsewhere classified"                      
[360] "Personal care workers"                                       
[361] "Child care workers and teachers' aides"                      
[362] "Child care workers"                                          
[363] "Teachers' aides"                                             
[364] "Personal care workers in health services"                    
[365] "Health care assistants"                                      
[366] "Home-based personal care workers"                            
[367] "Personal care workers in health services not elsewhere class"
[368] "Protective services workers"                                 
[369] "Protective services workers"                                 
[370] "Fire-fighters"                                               
[371] "Police officers"                                             
[372] "Prison guards"                                               
[373] "Security guards"                                             
[374] "Protective services workers not elsewhere classified"        
[375] "Skilled agricultural, forestry and fishery workers"          
[376] "Market-oriented skilled agricultural workers"                
[377] "Market gardeners and crop growers"                           
[378] "Field crop and vegetable growers"                            
[379] "Tree and shrub crop growers"                                 
[380] "Gardeners, horticultural and nursery growers"                
[381] "Mixed crop growers"                                          
[382] "Animal producers"                                            
[383] "Livestock and dairy producers"                               
[384] "Poultry producers"                                           
[385] "Apiarists and sericulturists"                                
[386] "Animal producers not elsewhere classified"                   
[387] "Mixed crop and animal producers"                             
[388] "Market-oriented skilled forestry, fishery and hunting worker"
[389] "Forestry and related workers"                                
[390] "Fishery workers, hunters and trappers"                       
[391] "Aquaculture workers"                                         
[392] "Inland and coastal waters fishery workers"                   
[393] "Deep-sea fishery workers"                                    
[394] "Hunters and trappers"                                        
[395] "Subsistence farmers, fishers, hunters and gatherers"         
[396] "Subsistence crop farmers"                                    
[397] "Subsistence livestock farmers"                               
[398] "Subsistence mixed crop and livestock farmers"                
[399] "Subsistence fishers, hunters, trappers and gatherers"        
[400] "Craft and related trades workers"                            
[401] "Building and related trades workers, excluding electricians" 
[402] "Building frame and related trades workers"                   
[403] "House builders"                                              
[404] "Bricklayers and related workers"                             
[405] "Stonemasons, stone cutters, splitters and carvers"           
[406] "Concrete placers, concrete finishers and related workers"    
[407] "Carpenters and joiners"                                      
[408] "Building frame and related trades workers not elsewhere clas"
[409] "Building finishers and related trades workers"               
[410] "Roofers"                                                     
[411] "Floor layers and tile setters"                               
[412] "Plasterers"                                                  
[413] "Insulation workers"                                          
[414] "Glaziers"                                                    
[415] "Plumbers and pipe fitters"                                   
[416] "Air conditioning and refrigeration mechanics"                
[417] "Painters, building structure cleaners and related trades wor"
[418] "Painters and related workers"                                
[419] "Spray painters and varnishers"                               
[420] "Building structure cleaners"                                 
[421] "Metal, machinery and related trades workers"                 
[422] "Sheet and structural metal workers, moulders and welders, an"
[423] "Metal moulders and coremakers"                               
[424] "Welders and flamecutters"                                    
[425] "Sheet-metal workers"                                         
[426] "Structural-metal preparers and erectors"                     
[427] "Riggers and cable splicers"                                  
[428] "Blacksmiths, toolmakers and related trades workers"          
[429] "Blacksmiths, hammersmiths and forging press workers"         
[430] "Toolmakers and related workers"                              
[431] "Metal working machine tool setters and operators"            
[432] "Metal polishers, wheel grinders and tool sharpeners"         
[433] "Machinery mechanics and repairers"                           
[434] "Motor vehicle mechanics and repairers"                       
[435] "Aircraft engine mechanics and repairers"                     
[436] "Agricultural and industrial machinery mechanics and repairer"
[437] "Bicycle and related repairers"                               
[438] "Handicraft and printing workers"                             
[439] "Handicraft workers"                                          
[440] "Precision-instrument makers and repairers"                   
[441] "Musical instrument makers and tuners"                        
[442] "Jewellery and precious-metal workers"                        
[443] "Potters and related workers"                                 
[444] "Glass makers, cutters, grinders and finishers"               
[445] "Sign writers, decorative painters, engravers and etchers"    
[446] "Handicraft workers in wood, basketry and related materials"  
[447] "Handicraft workers in textile, leather and related materials"
[448] "Handicraft workers not elsewhere classified"                 
[449] "Printing trades workers"                                     
[450] "Pre-press technicians"                                       
[451] "Printers"                                                    
[452] "Print finishing and binding workers"                         
[453] "Electrical and electronic trades workers"                    
[454] "Electrical equipment installers and repairers"               
[455] "Building and related electricians"                           
[456] "Electrical mechanics and fitters"                            
[457] "Electrical line installers and repairers"                    
[458] "Electronics and telecommunications installers and repairers" 
[459] "Electronics mechanics and servicers"                         
[460] "Information and communications technology installers and ser"
[461] "Food processing, wood working, garment and other craft and r"
[462] "Food processing and related trades workers"                  
[463] "Butchers, fishmongers and related food preparers"            
[464] "Bakers, pastry-cooks and confectionery makers"               
[465] "Dairy-products makers"                                       
[466] "Fruit, vegetable and related preservers"                     
[467] "Food and beverage tasters and graders"                       
[468] "Tobacco preparers and tobacco products makers"               
[469] "Wood treaters, cabinet-makers and related trades workers"    
[470] "Wood treaters"                                               
[471] "Cabinet-makers and related workers"                          
[472] "Woodworking-machine tool setters and operators"              
[473] "Garment and related trades workers"                          
[474] "Tailors, dressmakers, furriers and hatters"                  
[475] "Garment and related pattern-makers and cutters"              
[476] "Sewing, embroidery and related workers"                      
[477] "Upholsterers and related workers"                            
[478] "Pelt dressers, tanners and fellmongers"                      
[479] "Shoemakers and related workers"                              
[480] "Other craft and related workers"                             
[481] "Underwater divers"                                           
[482] "Shotfirers and blasters"                                     
[483] "Product graders and testers (excluding foods and beverages)" 
[484] "Fumigators and other pest and weed controllers"              
[485] "Craft and related workers not elsewhere classified"          
[486] "Plant and machine operators, and assemblers"                 
[487] "Stationary plant and machine operators"                      
[488] "Mining and mineral processing plant operators"               
[489] "Miners and quarriers"                                        
[490] "Mineral and stone processing plant operators"                
[491] "Well drillers and borers and related workers"                
[492] "Cement, stone and other mineral products machine operators"  
[493] "Metal processing and finishing plant operators"              
[494] "Metal processing plant operators"                            
[495] "Metal finishing, plating and coating machine operators"      
[496] "Chemical and photographic products plant and machine operato"
[497] "Chemical products plant and machine operators"               
[498] "Photographic products machine operators"                     
[499] "Rubber, plastic and paper products machine operators"        
[500] "Rubber products machine operators"                           
[501] "Plastic products machine operators"                          
[502] "Paper products machine operators"                            
[503] "Textile, fur and leather products machine operators"         
[504] "Fibre preparing, spinning and winding machine operators"     
[505] "Weaving and knitting machine operators"                      
[506] "Sewing machine operators"                                    
[507] "Bleaching, dyeing and fabric cleaning machine operators"     
[508] "Fur and leather preparing machine operators"                 
[509] "Shoemaking and related machine operators"                    
[510] "Laundry machine operators"                                   
[511] "Textile, fur and leather products machine operators not else"
[512] "Food and related products machine operators"                 
[513] "Wood processing and papermaking plant operators"             
[514] "Pulp and papermaking plant operators"                        
[515] "Wood processing plant operators"                             
[516] "Other stationary plant and machine operators"                
[517] "Glass and ceramics plant operators"                          
[518] "Steam engine and boiler operators"                           
[519] "Packing, bottling and labelling machine operators"           
[520] "Stationary plant and machine operators not elsewhere classif"
[521] "Assemblers"                                                  
[522] "Assemblers"                                                  
[523] "Mechanical machinery assemblers"                             
[524] "Electrical and electronic equipment assemblers"              
[525] "Assemblers not elsewhere classified"                         
[526] "Drivers and mobile plant operators"                          
[527] "Locomotive engine drivers and related workers"               
[528] "Locomotive engine drivers"                                   
[529] "Railway brake, signal and switch operators"                  
[530] "Car, van and motorcycle drivers"                             
[531] "Motorcycle drivers"                                          
[532] "Car, taxi and van drivers"                                   
[533] "Heavy truck and bus drivers"                                 
[534] "Bus and tram drivers"                                        
[535] "Heavy truck and lorry drivers"                               
[536] "Mobile plant operators"                                      
[537] "Mobile farm and forestry plant operators"                    
[538] "Earthmoving and related plant operators"                     
[539] "Crane, hoist and related plant operators"                    
[540] "Lifting truck operators"                                     
[541] "Ships' deck crews and related workers"                       
[542] "Elementary occupations"                                      
[543] "Cleaners and helpers"                                        
[544] "Domestic, hotel and office cleaners and helpers"             
[545] "Domestic cleaners and helpers"                               
[546] "Cleaners and helpers in offices, hotels and other establishm"
[547] "Vehicle, window, laundry and other hand cleaning workers"    
[548] "Hand launderers and pressers"                                
[549] "Vehicle cleaners"                                            
[550] "Window cleaners"                                             
[551] "Other cleaning workers"                                      
[552] "Agricultural, forestry and fishery labourers"                
[553] "Agricultural, forestry and fishery labourers"                
[554] "Crop farm labourers"                                         
[555] "Livestock farm labourers"                                    
[556] "Mixed crop and livestock farm labourers"                     
[557] "Garden and horticultural labourers"                          
[558] "Forestry labourers"                                          
[559] "Fishery and aquaculture labourers"                           
[560] "Labourers in mining, construction, manufacturing and transpo"
[561] "Mining and construction labourers"                           
[562] "Mining and quarrying labourers"                              
[563] "Civil engineering labourers"                                 
[564] "Building construction labourers"                             
[565] "Manufacturing labourers"                                     
[566] "Hand packers"                                                
[567] "Manufacturing labourers not elsewhere classified"            
[568] "Transport and storage labourers"                             
[569] "Hand and pedal vehicle drivers"                              
[570] "Drivers of animal-drawn vehicles and machinery"              
[571] "Freight handlers"                                            
[572] "Shelf fillers"                                               
[573] "Food preparation assistants"                                 
[574] "Food preparation assistants"                                 
[575] "Fast food preparers"                                         
[576] "Kitchen helpers"                                             
[577] "Street and related sales and service workers"                
[578] "Street and related service workers"                          
[579] "Street vendors (excluding food)"                             
[580] "Refuse workers and other elementary workers"                 
[581] "Refuse workers"                                              
[582] "Garbage and recycling collectors"                            
[583] "Refuse sorters"                                              
[584] "Sweepers and related labourers"                              
[585] "Other elementary workers"                                    
[586] "Messengers, package deliverers and luggage porters"          
[587] "Odd job persons"                                             
[588] "Meter readers and vending-machine collectors"                
[589] "Water and firewood collectors"                               
[590] "Elementary workers not elsewhere classified"                 
[591] "Not applicable"                                              
[592] "Refusal"                                                     
[593] "Don't know"                                                  
[594] "No answer"                                                   

$class
[1] "factor"


> #ESS6, ESS7: What is/was the name or title of your main job? 
> #In your main job, what kind of work do/did you do most of the time? 
> #What training or qualifications are/were needed for the job?
> data$occupation[as.numeric(data$isco08)>=0&as.numeric(data$isco08)<8]<-"Armed forces occupations"

> data$occupation[as.numeric(data$isco08)>=8&as.numeric(data$isco08)<52]<-"Managers"

> data$occupation[as.numeric(data$isco08)>=52&as.numeric(data$isco08)<171]<-"Professionals"

> data$occupation[as.numeric(data$isco08)>=171&as.numeric(data$isco08)<279]<-"Technicians and associate professionals"

> data$occupation[as.numeric(data$isco08)>=279&as.numeric(data$isco08)<319]<-"Clerical support workers"

> data$occupation[as.numeric(data$isco08)>=319&as.numeric(data$isco08)<375]<-"Service and sales workers"

> data$occupation[as.numeric(data$isco08)>=375&as.numeric(data$isco08)<400]<-"Skilled agricultural, forestry and fishery workers"

> data$occupation[as.numeric(data$isco08)>=400&as.numeric(data$isco08)<486]<-"Craft and related trades workers"

> data$occupation[as.numeric(data$isco08)>=486&as.numeric(data$isco08)<542]<-"Plant and machine operators and assemblers"

> data$occupation[as.numeric(data$isco08)>=542&as.numeric(data$isco08)<=591]<-"Elementary occupations"

> table(data$occupation)

                          Armed forces occupations 
                                               573 
                          Clerical support workers 
                                             18954 
                  Craft and related trades workers 
                                             19650 
                            Elementary occupations 
                                             18020 
                                          Managers 
                                             14605 
        Plant and machine operators and assemblers 
                                             12517 
                                     Professionals 
                                             27124 
                         Service and sales workers 
                                             29237 
Skilled agricultural, forestry and fishery workers 
                                              5397 
           Technicians and associate professionals 
                                             28164 

> ##########################
> 
> 
> ##########################
> #Occupation Risk
> ##########################
> 
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> 
> ##########################
> #Add unemployment risk to ESS 
> ##########################
> #By country and year
> 
> 
> ##########################
> #Austria
> ##########################
> 
> country="Austria"

> cntry<-"AT"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+                                                           , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+                                                           , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$unemployment)
< table of extent 0 >

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0194376952447067  0.023341049382716 0.0242544731610338 0.0248179120582681 
               469                154                439                 61                268 
0.0295730980205104 0.0422836752899197 0.0426995042379658 0.0470430107526882 0.0502816607552681 
               247                292                197                 76                509 
0.0516417910447761 0.0649717514124294 0.0654566518632941 0.0755026672137874             0.0765 
               154                333                179                 72                206 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0194376952447067 0.0201068974293713  0.023341049382716 0.0242544731610338 
               469                154                259                439                 61 
0.0243547800799709 0.0248179120582681 0.0295730980205104 0.0300982800982801   0.04203013481364 
               139                268                247                375                384 
0.0422836752899197 0.0426995042379658 0.0468945766959012 0.0470430107526882 0.0502816607552681 
               292                197                226                 76                509 
0.0516417910447761 0.0527306967984934  0.058057312988463 0.0649717514124294 0.0654566518632941 
               154                 78                454                333                179 
0.0755026672137874             0.0765 0.0850873264666368 
                72                206                181 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0194376952447067 0.0201068974293713  0.023341049382716 0.0242544731610338 
               469                154                259                439                 61 
0.0243547800799709 0.0248179120582681 0.0295730980205104 0.0300982800982801   0.04203013481364 
               139                268                247                375                384 
0.0422836752899197 0.0426995042379658 0.0468945766959012 0.0470430107526882 0.0502816607552681 
               292                197                226                 76                509 
0.0516417910447761 0.0527306967984934  0.058057312988463 0.0649717514124294 0.0654566518632941 
               154                 78                454                333                179 
0.0755026672137874             0.0765 0.0850873264666368 
                72                206                181 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> #Change parameter values
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0194376952447067 0.0201068974293713  0.023341049382716 0.0242544731610338 
               469                154                259                439                 61 
0.0243547800799709 0.0248179120582681 0.0295730980205104 0.0300982800982801   0.04203013481364 
               139                268                247                375                384 
0.0422836752899197 0.0426995042379658 0.0468945766959012 0.0470430107526882 0.0502816607552681 
               292                197                226                 76                509 
0.0516417910447761 0.0527306967984934  0.058057312988463 0.0649717514124294 0.0654566518632941 
               154                 78                454                333                179 
0.0755026672137874             0.0765 0.0850873264666368 
                72                206                181 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0194376952447067 0.0201068974293713  0.023341049382716 0.0242544731610338 
               469                154                259                439                 61 
0.0243547800799709 0.0248179120582681 0.0295730980205104 0.0300982800982801   0.04203013481364 
               139                268                247                375                384 
0.0422836752899197 0.0426995042379658 0.0468945766959012 0.0470430107526882 0.0502816607552681 
               292                197                226                 76                509 
0.0516417910447761 0.0527306967984934  0.058057312988463 0.0649717514124294 0.0654566518632941 
               154                 78                454                333                179 
0.0755026672137874             0.0765 0.0850873264666368 
                72                206                181 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+       , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+     , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0194376952447067 0.0201068974293713  0.023341049382716 0.0242544731610338 
               469                154                259                439                 61 
0.0243547800799709 0.0248179120582681 0.0266724967205947 0.0295730980205104 0.0299939283545841 
               139                268                198                247                228 
0.0300982800982801 0.0315893385982231   0.04203013481364 0.0422836752899197 0.0426995042379658 
               375                 97                384                292                197 
 0.044525215810995 0.0468945766959012 0.0470430107526882 0.0502816607552681 0.0516417910447761 
               226                226                 76                509                154 
0.0527306967984934 0.0572625698324022  0.058057312988463  0.061569416498994 0.0636079249217935 
                78                208                454                111                341 
0.0649717514124294 0.0654566518632941 0.0755026672137874             0.0765 0.0850873264666368 
               333                179                 72                206                181 
 0.103008945513689 
               167 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> 
> ##########################
> #Belgium
> ##########################
> 
> country="Belgium"

> cntry<-"BE"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0172651069685975 0.0194376952447067 0.0201068974293713  0.023341049382716 
               469                273                154                259                439 
0.0242544731610338 0.0243547800799709 0.0248179120582681 0.0266724967205947 0.0295730980205104 
                61                139                268                198                247 
0.0299939283545841 0.0300982800982801 0.0308211473565804 0.0315893385982231 0.0343403607911324 
               228                375                114                 97                235 
0.0362541993281075   0.04203013481364 0.0422836752899197 0.0426995042379658  0.044525215810995 
               183                384                292                197                226 
0.0468945766959012 0.0470430107526882 0.0502816607552681 0.0509113764927718 0.0516417910447761 
               226                 76                509                224                154 
0.0527306967984934 0.0572625698324022  0.058057312988463 0.0605714285714286  0.061569416498994 
                78                208                454                150                111 
0.0636079249217935 0.0649717514124294 0.0654566518632941 0.0755026672137874             0.0765 
               341                333                179                 72                206 
0.0775623268698061 0.0850873264666368 0.0926889714993804  0.103008945513689 
               214                181                144                167 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0172651069685975 0.0194376952447067 0.0201068974293713  0.023341049382716 
               469                273                154                259                439 
0.0239011309315612 0.0242544731610338 0.0243547800799709 0.0248179120582681 0.0253881661770877 
               227                 61                139                268                203 
0.0266724967205947 0.0295730980205104 0.0299939283545841 0.0300982800982801 0.0308211473565804 
               198                247                228                375                114 
0.0315893385982231 0.0343403607911324 0.0362541993281075   0.04203013481364 0.0422836752899197 
                97                235                183                384                292 
0.0426995042379658  0.044525215810995 0.0467409948542024 0.0467555821969129 0.0468945766959012 
               197                226                221                221                226 
0.0470430107526882 0.0502816607552681 0.0509113764927718 0.0516417910447761 0.0527306967984934 
                76                509                224                154                 78 
0.0572625698324022  0.058057312988463 0.0605714285714286  0.061569416498994 0.0636079249217935 
               208                454                150                111                341 
0.0641271581255138 0.0649717514124294 0.0654566518632941 0.0659246575342466 0.0753043119455333 
                88                333                179                214                176 
0.0755026672137874             0.0765 0.0775623268698061 0.0850873264666368 0.0926889714993804 
                72                206                214                181                144 
 0.103008945513689  0.108005366726297 
               167                171 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0172651069685975 0.0194376952447067 0.0201068974293713  0.023341049382716 
               469                273                154                259                439 
0.0239011309315612 0.0242544731610338 0.0243547800799709 0.0248179120582681 0.0251697962445066 
               227                 61                139                268                153 
0.0253881661770877 0.0257910706545297 0.0266724967205947 0.0295730980205104 0.0299939283545841 
               203                259                198                247                228 
0.0300982800982801 0.0308211473565804 0.0315893385982231 0.0343403607911324 0.0362541993281075 
               375                114                 97                235                183 
  0.04203013481364 0.0422836752899197 0.0426995042379658 0.0433547898523287  0.044525215810995 
               384                292                197                312                226 
0.0467409948542024 0.0467555821969129 0.0468945766959012 0.0470430107526882 0.0482456140350877 
               221                221                226                 76                 35 
0.0502816607552681 0.0509113764927718 0.0516417910447761  0.052053981907163 0.0527306967984934 
               509                224                154                167                 78 
0.0572625698324022  0.058057312988463 0.0605714285714286  0.061569416498994 0.0636079249217935 
               208                454                150                111                341 
0.0641271581255138 0.0649717514124294 0.0654566518632941 0.0659246575342466 0.0710715061943056 
                88                333                179                214                125 
0.0753043119455333 0.0755026672137874             0.0765 0.0775623268698061 0.0795717592592593 
               176                 72                206                214                146 
0.0850873264666368 0.0926889714993804 0.0951444859445646   0.10270393092479  0.103008945513689 
               181                144                209                157                167 
 0.108005366726297 
               171 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0172651069685975 0.0194376952447067 0.0201068974293713 0.0217617659308621 
               469                273                154                259                247 
 0.023341049382716 0.0236710130391174 0.0239011309315612 0.0242544731610338 0.0243547800799709 
               439                216                227                 61                139 
0.0248179120582681 0.0251697962445066 0.0253881661770877 0.0257910706545297 0.0266724967205947 
               268                153                203                259                198 
0.0279437271150511 0.0295730980205104 0.0299939283545841 0.0300982800982801 0.0308211473565804 
               234                247                228                375                114 
0.0315893385982231 0.0343403607911324 0.0362541993281075   0.04203013481364 0.0422836752899197 
                97                235                183                384                292 
0.0426995042379658 0.0433547898523287 0.0435029049171036  0.044525215810995 0.0467409948542024 
               197                312                177                226                221 
0.0467555821969129 0.0468945766959012 0.0470430107526882 0.0482456140350877 0.0496535796766744 
               221                226                 76                 35                 37 
0.0502816607552681 0.0509113764927718 0.0516417910447761  0.052053981907163 0.0527306967984934 
               509                224                154                167                 78 
0.0542635658914729 0.0572625698324022  0.058057312988463 0.0605714285714286  0.061569416498994 
               149                208                454                150                111 
0.0636079249217935 0.0641271581255138 0.0643896976483763 0.0649717514124294 0.0654566518632941 
               341                 88                157                333                179 
0.0659246575342466 0.0710715061943056 0.0753043119455333 0.0755026672137874             0.0765 
               214                125                176                 72                206 
 0.077457264957265 0.0775623268698061 0.0795717592592593 0.0850873264666368 0.0926889714993804 
               178                214                146                181                144 
0.0951444859445646 0.0964175143741707   0.10270393092479  0.103008945513689  0.108005366726297 
               209                149                157                167                171 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0172651069685975 0.0194376952447067 0.0201068974293713 0.0217617659308621 
               469                273                154                259                247 
 0.023341049382716 0.0236710130391174 0.0239011309315612 0.0242544731610338 0.0243547800799709 
               439                216                227                 61                139 
0.0248179120582681 0.0251697962445066 0.0253881661770877 0.0257910706545297 0.0266724967205947 
               268                153                203                259                198 
0.0267139027192646 0.0279437271150511 0.0295730980205104 0.0299939283545841 0.0300982800982801 
               260                234                247                228                375 
0.0308211473565804 0.0315893385982231 0.0343403607911324 0.0354838709677419 0.0362541993281075 
               114                 97                235                176                183 
  0.04203013481364 0.0422836752899197 0.0426995042379658 0.0433547898523287 0.0433574207893274 
               384                292                197                312                209 
0.0435029049171036  0.044525215810995 0.0467409948542024 0.0467555821969129 0.0468945766959012 
               177                226                221                221                226 
0.0470430107526882 0.0482456140350877 0.0496535796766744 0.0502816607552681 0.0509113764927718 
                76                 35                 37                509                224 
0.0516417910447761  0.052053981907163 0.0526235972095845 0.0527306967984934 0.0542635658914729 
               154                167                204                 78                149 
0.0572625698324022  0.058057312988463 0.0605700712589074 0.0605714285714286  0.061569416498994 
               208                454                 27                150                111 
0.0636079249217935 0.0641271581255138 0.0643896976483763 0.0649717514124294 0.0654566518632941 
               341                 88                157                333                179 
0.0659246575342466 0.0710715061943056 0.0731810490693739 0.0753043119455333 0.0755026672137874 
               214                125                147                176                 72 
            0.0765  0.077457264957265 0.0775623268698061 0.0795717592592593 0.0850873264666368 
               206                178                214                146                181 
0.0879211175020542 0.0926889714993804 0.0946155169447789 0.0951444859445646 0.0964175143741707 
               110                144                163                209                149 
0.0990077653149267   0.10270393092479  0.103008945513689  0.108005366726297 
               185                157                167                171 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0172651069685975 0.0182452374563992 0.0194376952447067 0.0201068974293713 
               469                273                211                154                259 
0.0217617659308621  0.023341049382716 0.0236710130391174 0.0239011309315612 0.0242544731610338 
               247                439                216                227                 61 
0.0243264977885002 0.0243547800799709 0.0248179120582681 0.0251697962445066 0.0253881661770877 
               307                139                268                153                203 
0.0257910706545297 0.0266724967205947 0.0267139027192646 0.0279437271150511 0.0286692340607617 
               259                198                260                234                290 
0.0295730980205104 0.0299939283545841 0.0300982800982801 0.0308211473565804 0.0315893385982231 
               247                228                375                114                 97 
0.0343403607911324 0.0354838709677419 0.0362541993281075   0.04203013481364 0.0422836752899197 
               235                176                183                384                292 
0.0426995042379658 0.0433547898523287 0.0433574207893274 0.0435029049171036  0.044525215810995 
               197                312                209                177                226 
0.0467409948542024 0.0467555821969129 0.0468945766959012 0.0470430107526882 0.0482456140350877 
               221                221                226                 76                 35 
0.0496535796766744 0.0502816607552681 0.0509113764927718 0.0516417910447761  0.052053981907163 
                37                509                224                154                167 
0.0522693757168606 0.0526235972095845 0.0527306967984934 0.0542635658914729 0.0572625698324022 
               165                204                 78                149                208 
 0.058057312988463 0.0605700712589074 0.0605714285714286  0.061569416498994 0.0636079249217935 
               454                 27                150                111                341 
0.0641271581255138 0.0643896976483763 0.0649717514124294 0.0654566518632941 0.0659246575342466 
                88                157                333                179                214 
0.0691703391454302 0.0710715061943056 0.0731810490693739 0.0734780628510703  0.074849349825563 
               148                125                147                227                127 
0.0753043119455333 0.0755026672137874             0.0765  0.077457264957265 0.0775623268698061 
               176                 72                206                178                214 
0.0795717592592593 0.0850873264666368 0.0879211175020542 0.0926889714993804 0.0946155169447789 
               146                181                110                144                163 
0.0951444859445646 0.0964175143741707 0.0990077653149267   0.10270393092479  0.103008945513689 
               209                149                185                157                167 
 0.108005366726297  0.108166470357283 
               171                170 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0140120610145442 0.0172651069685975 0.0182452374563992 0.0194376952447067 0.0201068974293713 
               469                273                211                154                259 
0.0217617659308621  0.023341049382716 0.0236710130391174 0.0239011309315612 0.0242544731610338 
               247                439                216                227                 61 
0.0243264977885002 0.0243547800799709 0.0248179120582681 0.0251697962445066 0.0253881661770877 
               307                139                268                153                203 
0.0257910706545297 0.0261760937213985 0.0266724967205947 0.0267139027192646 0.0279437271150511 
               259                306                198                260                234 
0.0286692340607617 0.0295730980205104 0.0299939283545841 0.0300982800982801 0.0308211473565804 
               290                247                228                375                114 
0.0312345066931086 0.0315893385982231 0.0343403607911324 0.0349115972430327 0.0354838709677419 
               168                 97                235                291                176 
0.0362541993281075   0.04203013481364 0.0422836752899197 0.0426995042379658 0.0433547898523287 
               183                384                292                197                312 
0.0433574207893274 0.0435029049171036  0.044525215810995 0.0467409948542024 0.0467555821969129 
               209                177                226                221                221 
0.0468945766959012 0.0470430107526882 0.0482456140350877 0.0496535796766744 0.0502816607552681 
               226                 76                 35                 37                509 
0.0509113764927718 0.0516417910447761  0.052053981907163 0.0522693757168606 0.0526235972095845 
               224                154                167                165                204 
0.0527306967984934 0.0542635658914729 0.0572625698324022  0.058057312988463 0.0605700712589074 
                78                149                208                454                 27 
0.0605714285714286  0.061569416498994 0.0636079249217935 0.0641271581255138 0.0643896976483763 
               150                111                341                 88                157 
0.0649717514124294 0.0654566518632941 0.0659246575342466 0.0664614270191959 0.0691703391454302 
               333                179                214                140                148 
0.0710715061943056 0.0731810490693739 0.0734780628510703  0.074849349825563 0.0753043119455333 
               125                147                227                127                176 
0.0755026672137874             0.0765 0.0771307365985345  0.077457264957265 0.0775623268698061 
                72                206                144                178                214 
0.0795717592592593 0.0799757649197213 0.0808438558669541 0.0850873264666368 0.0879211175020542 
               146                126                174                181                110 
0.0926889714993804 0.0946155169447789 0.0951444859445646 0.0964175143741707 0.0990077653149267 
               144                163                209                149                185 
 0.102649006622517   0.10270393092479  0.103008945513689  0.108005366726297  0.108166470357283 
               184                157                167                171                170 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> ##########################
> #Switzerland
> ##########################
> 
> country="Switzerland"

> cntry<-"CH"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0128509045539613 0.0140120610145442 0.0172651069685975 0.0182452374563992 0.0194376952447067 
               411                469                273                211                154 
0.0201068974293713  0.020628078817734 0.0217617659308621 0.0217782577393808  0.023341049382716 
               259                328                247                273                439 
0.0236710130391174 0.0239011309315612 0.0242544731610338 0.0243264977885002 0.0243547800799709 
               216                227                 61                307                139 
 0.024763619990995 0.0248179120582681 0.0251697962445066 0.0253881661770877 0.0257910706545297 
                86                268                153                203                259 
 0.026079869600652 0.0261760937213985 0.0266724967205947 0.0267139027192646 0.0279437271150511 
               213                306                198                260                234 
0.0286692340607617 0.0295730980205104 0.0299939283545841 0.0300982800982801 0.0308211473565804 
               290                247                228                375                114 
0.0312345066931086  0.031377415351888 0.0315893385982231 0.0325693606755127 0.0343403607911324 
               168                254                 97                166                235 
0.0349115972430327 0.0354838709677419 0.0356612184249629 0.0362541993281075   0.04203013481364 
               291                176                 76                183                384 
0.0422836752899197 0.0426995042379658 0.0433547898523287 0.0433574207893274 0.0435029049171036 
               292                197                312                209                177 
 0.044525215810995 0.0467409948542024 0.0467555821969129 0.0468945766959012 0.0470430107526882 
               226                221                221                226                 76 
0.0482456140350877 0.0496535796766744 0.0502816607552681 0.0509113764927718 0.0516417910447761 
                35                 37                509                224                154 
 0.052053981907163 0.0522693757168606 0.0526235972095845 0.0527306967984934 0.0542635658914729 
               167                165                204                 78                149 
0.0572625698324022  0.058057312988463 0.0605700712589074 0.0605714285714286  0.061569416498994 
               208                454                 27                150                111 
0.0636079249217935 0.0641271581255138 0.0643896976483763 0.0649717514124294 0.0654566518632941 
               341                 88                157                333                179 
0.0659246575342466 0.0664614270191959 0.0691703391454302 0.0710715061943056 0.0731810490693739 
               214                140                148                125                147 
0.0734780628510703  0.074849349825563 0.0753043119455333 0.0755026672137874             0.0765 
               227                127                176                 72                206 
0.0771307365985345  0.077457264957265 0.0775623268698061 0.0795717592592593 0.0799757649197213 
               144                178                214                146                126 
0.0808438558669541 0.0850873264666368 0.0879211175020542 0.0926889714993804 0.0946155169447789 
               174                181                110                144                163 
0.0951444859445646 0.0964175143741707 0.0990077653149267  0.102649006622517   0.10270393092479 
               209                149                185                184                157 
 0.103008945513689  0.108005366726297  0.108166470357283 
               167                171                170 

> ##########################
> 
> 
> #Extract average unemployment rate
> 
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0128509045539613 0.0140120610145442 0.0172651069685975 0.0182452374563992 0.0194376952447067 
               411                469                273                211                154 
0.0201068974293713  0.020628078817734 0.0217617659308621 0.0217782577393808 0.0227412415488629 
               259                328                247                273                 90 
0.0230348401957961  0.023341049382716 0.0236710130391174 0.0237923576063446 0.0239011309315612 
               281                439                216                475                227 
0.0242544731610338 0.0243264977885002 0.0243547800799709  0.024763619990995 0.0248179120582681 
                61                307                139                 86                268 
0.0251697962445066 0.0253881661770877 0.0257910706545297  0.026079869600652 0.0261760937213985 
               153                203                259                213                306 
0.0266724967205947 0.0267139027192646 0.0279437271150511 0.0286692340607617 0.0295730980205104 
               198                260                234                290                247 
0.0298372513562387 0.0299939283545841 0.0300982800982801 0.0308211473565804 0.0312345066931086 
               176                228                375                114                168 
 0.031377415351888 0.0315893385982231 0.0325693606755127 0.0343403607911324 0.0349115972430327 
               254                 97                166                235                291 
0.0354838709677419 0.0356612184249629 0.0362541993281075 0.0367789392179636 0.0391606080634501 
               176                 76                183                148                237 
  0.04203013481364 0.0422836752899197 0.0426995042379658 0.0433547898523287 0.0433574207893274 
               384                292                197                312                209 
0.0435029049171036  0.044525215810995 0.0467409948542024 0.0467555821969129 0.0468945766959012 
               177                226                221                221                226 
0.0470430107526882  0.047542735042735 0.0475452196382429 0.0482456140350877 0.0496535796766744 
                76                302                 62                 35                 37 
0.0502816607552681 0.0509113764927718 0.0516417910447761  0.052053981907163 0.0522693757168606 
               509                224                154                167                165 
0.0526235972095845 0.0527306967984934  0.053840499816244 0.0542635658914729 0.0572625698324022 
               204                 78                239                149                208 
 0.058057312988463 0.0605700712589074 0.0605714285714286  0.061569416498994 0.0636079249217935 
               454                 27                150                111                341 
0.0641271581255138 0.0643896976483763 0.0649717514124294 0.0654566518632941 0.0659246575342466 
                88                157                333                179                214 
0.0664614270191959 0.0691703391454302 0.0710715061943056 0.0731810490693739 0.0734780628510703 
               140                148                125                147                227 
 0.074849349825563 0.0753043119455333 0.0755026672137874             0.0765 0.0771307365985345 
               127                176                 72                206                144 
 0.077457264957265 0.0775623268698061 0.0795717592592593 0.0799757649197213 0.0808438558669541 
               178                214                146                126                174 
0.0850873264666368 0.0879211175020542 0.0926889714993804 0.0946155169447789 0.0951444859445646 
               181                110                144                163                209 
0.0964175143741707 0.0990077653149267  0.102649006622517   0.10270393092479  0.103008945513689 
               149                185                184                157                167 
 0.108005366726297  0.108166470357283 
               171                170 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0128509045539613 0.0140120610145442 0.0164333536214242 0.0172651069685975 0.0172739541160594 
               411                469                 56                273                230 
0.0182452374563992 0.0194376952447067 0.0201068974293713  0.020628078817734 0.0217065004041104 
               211                154                259                328                450 
0.0217617659308621 0.0217782577393808 0.0227412415488629 0.0230348401957961  0.023341049382716 
               247                273                 90                281                439 
0.0236710130391174 0.0237923576063446 0.0239011309315612 0.0242544731610338 0.0243264977885002 
               216                475                227                 61                307 
0.0243547800799709 0.0246305418719212  0.024763619990995 0.0248179120582681 0.0251697962445066 
               139                109                 86                268                153 
0.0253881661770877 0.0257910706545297  0.026079869600652 0.0261760937213985 0.0266724967205947 
               203                259                213                306                198 
0.0267139027192646 0.0279437271150511 0.0286692340607617 0.0295730980205104 0.0298372513562387 
               260                234                290                247                176 
0.0299939283545841 0.0300982800982801 0.0301942222947609 0.0308211473565804 0.0312345066931086 
               228                375                169                114                168 
 0.031377415351888 0.0315893385982231 0.0325693606755127 0.0343403607911324 0.0349115972430327 
               254                 97                166                235                291 
0.0354838709677419 0.0356612184249629 0.0362541993281075 0.0367789392179636 0.0391606080634501 
               176                 76                183                148                237 
0.0412642669007902   0.04203013481364 0.0422836752899197 0.0426995042379658 0.0433547898523287 
               198                384                292                197                312 
0.0433574207893274 0.0435029049171036 0.0436484634957917  0.044525215810995 0.0467409948542024 
               209                177                227                226                221 
0.0467555821969129 0.0468945766959012 0.0470430107526882  0.047542735042735 0.0475452196382429 
               221                226                 76                302                 62 
0.0477157360406091 0.0482456140350877 0.0496535796766744 0.0502816607552681 0.0509113764927718 
                64                 35                 37                509                224 
0.0516417910447761  0.052053981907163 0.0522693757168606 0.0526235972095845 0.0527306967984934 
               154                167                165                204                 78 
 0.053840499816244 0.0541623127830024 0.0542635658914729 0.0572625698324022  0.058057312988463 
               239                225                149                208                454 
0.0605700712589074 0.0605714285714286  0.061569416498994 0.0636079249217935 0.0641271581255138 
                27                150                111                341                 88 
0.0643896976483763 0.0649717514124294 0.0654566518632941 0.0659246575342466 0.0664614270191959 
               157                333                179                214                140 
0.0691703391454302 0.0710715061943056 0.0731810490693739 0.0734780628510703  0.074849349825563 
               148                125                147                227                127 
0.0753043119455333 0.0755026672137874             0.0765 0.0771307365985345  0.077457264957265 
               176                 72                206                144                178 
0.0775623268698061 0.0795717592592593 0.0799757649197213 0.0808438558669541 0.0850873264666368 
               214                146                126                174                181 
0.0879211175020542 0.0926889714993804 0.0946155169447789 0.0951444859445646 0.0964175143741707 
               110                144                163                209                149 
0.0990077653149267  0.102649006622517   0.10270393092479  0.103008945513689  0.108005366726297 
               185                184                157                167                171 
 0.108166470357283 
               170 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.0128509045539613 0.0140120610145442  0.015375854214123 0.0164333536214242 0.0172651069685975 
               411                469                 40                 56                273 
0.0172739541160594 0.0174951994879454 0.0178593575592211 0.0182452374563992 0.0194376952447067 
               230                463                227                211                154 
0.0201068974293713  0.020628078817734 0.0217065004041104 0.0217617659308621 0.0217782577393808 
               259                328                450                247                273 
0.0227412415488629 0.0230348401957961  0.023341049382716 0.0236710130391174 0.0237923576063446 
                90                281                439                216                475 
0.0239011309315612 0.0242544731610338 0.0243264977885002 0.0243547800799709 0.0246305418719212 
               227                 61                307                139                109 
 0.024763619990995 0.0248179120582681 0.0251697962445066 0.0253881661770877 0.0256829707181417 
                86                268                153                203                187 
0.0257910706545297  0.026079869600652 0.0261760937213985 0.0264531848242255 0.0266724967205947 
               259                213                306                166                198 
0.0267139027192646 0.0279437271150511  0.027964785085448 0.0286692340607617 0.0292200966996006 
               260                234                 65                290                174 
0.0295730980205104 0.0298372513562387 0.0299939283545841 0.0300982800982801 0.0301942222947609 
               247                176                228                375                169 
0.0308211473565804 0.0312345066931086  0.031377415351888 0.0315893385982231 0.0325693606755127 
               114                168                254                 97                166 
0.0343403607911324 0.0349115972430327 0.0354838709677419 0.0356612184249629 0.0362541993281075 
               235                291                176                 76                183 
0.0367789392179636 0.0383953168044077 0.0391606080634501 0.0412642669007902   0.04203013481364 
               148                231                237                198                384 
0.0422836752899197 0.0426995042379658 0.0433547898523287 0.0433574207893274 0.0435029049171036 
               292                197                312                209                177 
0.0436484634957917  0.044525215810995 0.0461725394896719 0.0467409948542024 0.0467555821969129 
               227                226                125                221                221 
0.0468945766959012 0.0470430107526882  0.047542735042735 0.0475452196382429 0.0477157360406091 
               226                 76                302                 62                 64 
0.0482456140350877 0.0496535796766744 0.0502816607552681 0.0509113764927718 0.0516417910447761 
                35                 37                509                224                154 
 0.052053981907163 0.0522693757168606 0.0526235972095845 0.0527306967984934  0.053840499816244 
               167                165                204                 78                239 
0.0541623127830024 0.0542635658914729 0.0572625698324022  0.058057312988463 0.0605700712589074 
               225                149                208                454                 27 
0.0605714285714286  0.061569416498994 0.0636079249217935 0.0641271581255138 0.0643896976483763 
               150                111                341                 88                157 
0.0649717514124294 0.0654566518632941 0.0659246575342466 0.0664614270191959 0.0691703391454302 
               333                179                214                140                148 
0.0710715061943056 0.0731810490693739 0.0734780628510703  0.074849349825563 0.0753043119455333 
               125                147                227                127                176 
0.0755026672137874             0.0765 0.0771307365985345  0.077457264957265 0.0775623268698061 
                72                206                144                178                214 
0.0795717592592593 0.0799757649197213 0.0808438558669541 0.0850873264666368 0.0879211175020542 
               146                126                174                181                110 
0.0926889714993804 0.0946155169447789 0.0951444859445646 0.0964175143741707 0.0990077653149267 
               144                163                209                149                185 
 0.102649006622517   0.10270393092479  0.103008945513689  0.108005366726297  0.108166470357283 
               184                157                167                171                170 

> ##########################
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00844155844155844  0.0128509045539613  0.0140120610145442    0.01517663563321 
                 54                 411                 469                 226 
  0.015375854214123  0.0164333536214242  0.0165365653245686  0.0172651069685975 
                 40                  56                 338                 273 
 0.0172739541160594  0.0174951994879454  0.0178593575592211  0.0182452374563992 
                230                 463                 227                 211 
 0.0194376952447067  0.0201068974293713   0.020628078817734  0.0217065004041104 
                154                 259                 328                 450 
 0.0217617659308621  0.0217782577393808  0.0220403022670025  0.0227412415488629 
                247                 273                  83                  90 
 0.0230348401957961   0.023341049382716  0.0236710130391174  0.0237923576063446 
                281                 439                 216                 475 
 0.0239011309315612  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                227                  61                 307                 139 
 0.0246305418719212   0.024763619990995  0.0248179120582681  0.0251697962445066 
                109                  86                 268                 153 
 0.0253881661770877  0.0256829707181417  0.0257910706545297   0.026079869600652 
                203                 187                 259                 213 
 0.0261760937213985  0.0264531848242255  0.0266724967205947  0.0267139027192646 
                306                 166                 198                 260 
 0.0269736842105263  0.0279437271150511   0.027964785085448  0.0286692340607617 
                200                 234                  65                 290 
  0.028899183763512  0.0292200966996006   0.029377657518361  0.0295730980205104 
                135                 174                  95                 247 
 0.0298372513562387  0.0299939283545841  0.0300982800982801  0.0301942222947609 
                176                 228                 375                 169 
 0.0308211473565804  0.0312345066931086   0.031377415351888  0.0315893385982231 
                114                 168                 254                  97 
 0.0325693606755127  0.0343403607911324  0.0347459003084916  0.0349115972430327 
                166                 235                 203                 291 
   0.03547209181012  0.0354838709677419  0.0356612184249629  0.0362541993281075 
                 45                 176                  76                 183 
 0.0367789392179636  0.0383953168044077  0.0391606080634501  0.0412642669007902 
                148                 231                 237                 198 
   0.04203013481364  0.0422836752899197  0.0426995042379658  0.0433547898523287 
                384                 292                 197                 312 
 0.0433574207893274  0.0435029049171036  0.0436484634957917   0.044525215810995 
                209                 177                 227                 226 
 0.0461725394896719  0.0467409948542024  0.0467555821969129  0.0468945766959012 
                125                 221                 221                 226 
 0.0470430107526882   0.047542735042735  0.0475452196382429  0.0477157360406091 
                 76                 302                  62                  64 
 0.0482456140350877  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                 35                  37                 509                 224 
 0.0516417910447761   0.052053981907163  0.0522693757168606  0.0526235972095845 
                154                 167                 165                 204 
 0.0527306967984934   0.053840499816244  0.0541623127830024  0.0542635658914729 
                 78                 239                 225                 149 
 0.0572625698324022   0.058057312988463  0.0605700712589074  0.0605714285714286 
                208                 454                  27                 150 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0649717514124294  0.0654566518632941  0.0659246575342466  0.0664614270191959 
                333                 179                 214                 140 
 0.0691703391454302  0.0710715061943056  0.0731810490693739  0.0734780628510703 
                148                 125                 147                 227 
  0.074849349825563  0.0753043119455333  0.0755026672137874              0.0765 
                127                 176                  72                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061  0.0795717592592593 
                144                 178                 214                 146 
 0.0799757649197213  0.0808438558669541  0.0850873264666368  0.0879211175020542 
                126                 174                 181                 110 
 0.0926889714993804  0.0946155169447789  0.0951444859445646  0.0964175143741707 
                144                 163                 209                 149 
 0.0990077653149267   0.102649006622517    0.10270393092479   0.103008945513689 
                185                 184                 157                 167 
  0.108005366726297   0.108166470357283 
                171                 170 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00793650793650794 0.00844155844155844  0.0128509045539613  0.0135225216646034 
                 41                  54                 411                 298 
 0.0140120610145442    0.01517663563321   0.015375854214123  0.0164333536214242 
                469                 226                  40                  56 
 0.0165365653245686    0.01692628480314  0.0172651069685975  0.0172739541160594 
                338                 262                 273                 230 
 0.0174951994879454  0.0177547118273696  0.0178593575592211  0.0182452374563992 
                463                 164                 227                 211 
 0.0194376952447067  0.0201068974293713   0.020628078817734  0.0217065004041104 
                154                 259                 328                 450 
 0.0217617659308621  0.0217782577393808  0.0220403022670025  0.0227412415488629 
                247                 273                  83                  90 
 0.0230348401957961  0.0230622919638611   0.023341049382716  0.0236710130391174 
                281                 127                 439                 216 
 0.0237923576063446  0.0239011309315612  0.0242544731610338  0.0243264977885002 
                475                 227                  61                 307 
 0.0243547800799709  0.0246305418719212   0.024763619990995  0.0248179120582681 
                139                 109                  86                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877  0.0256829707181417 
                166                 153                 203                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0266724967205947  0.0267139027192646  0.0269736842105263  0.0270528760759667 
                198                 260                 200                 243 
 0.0279437271150511   0.027964785085448  0.0286692340607617   0.028899183763512 
                234                  65                 290                 135 
 0.0292200966996006   0.029377657518361  0.0295730980205104  0.0298372513562387 
                174                  95                 247                 176 
 0.0299939283545841  0.0300982800982801  0.0301942222947609  0.0308211473565804 
                228                 375                 169                 114 
 0.0312345066931086   0.031377415351888  0.0315893385982231  0.0320326150262085 
                168                 254                  97                  56 
 0.0325693606755127  0.0343403607911324  0.0347459003084916  0.0349115972430327 
                166                 235                 203                 291 
 0.0350253807106599    0.03547209181012  0.0354838709677419  0.0356612184249629 
                 53                  45                 176                  76 
 0.0362541993281075  0.0367789392179636  0.0383953168044077  0.0391606080634501 
                183                 148                 231                 237 
 0.0412642669007902    0.04203013481364  0.0422836752899197  0.0426995042379658 
                198                 384                 292                 197 
 0.0433547898523287  0.0433574207893274  0.0435029049171036  0.0436484634957917 
                312                 209                 177                 227 
  0.044525215810995  0.0461725394896719  0.0467409948542024  0.0467555821969129 
                226                 125                 221                 221 
 0.0468945766959012  0.0470430107526882   0.047542735042735  0.0475452196382429 
                226                  76                 302                  62 
 0.0477157360406091  0.0482456140350877  0.0496535796766744  0.0502816607552681 
                 64                  35                  37                 509 
 0.0509113764927718  0.0516417910447761   0.052053981907163  0.0522693757168606 
                224                 154                 167                 165 
 0.0526235972095845  0.0527306967984934   0.053840499816244  0.0541623127830024 
                204                  78                 239                 225 
 0.0542635658914729  0.0572625698324022   0.058057312988463  0.0605700712589074 
                149                 208                 454                  27 
 0.0605714285714286   0.061569416498994  0.0636079249217935  0.0641271581255138 
                150                 111                 341                  88 
 0.0643896976483763  0.0649717514124294  0.0654566518632941  0.0659246575342466 
                157                 333                 179                 214 
 0.0664614270191959  0.0691703391454302  0.0710715061943056  0.0731810490693739 
                140                 148                 125                 147 
 0.0734780628510703   0.074849349825563  0.0753043119455333  0.0755026672137874 
                227                 127                 176                  72 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
 0.0795717592592593  0.0799757649197213  0.0808438558669541  0.0850873264666368 
                146                 126                 174                 181 
 0.0879211175020542  0.0926889714993804  0.0946155169447789  0.0951444859445646 
                110                 144                 163                 209 
 0.0964175143741707  0.0990077653149267   0.102649006622517    0.10270393092479 
                149                 185                 184                 157 
  0.103008945513689   0.108005366726297   0.108166470357283 
                167                 171                 170 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> #Change parameter values
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844  0.0128509045539613 
                 49                  41                  54                 411 
 0.0135111727005023  0.0135225216646034  0.0140120610145442    0.01517663563321 
                293                 298                 469                 226 
  0.015375854214123  0.0163260512097721  0.0164333536214242  0.0165365653245686 
                 40                 261                  56                 338 
   0.01692628480314  0.0172651069685975  0.0172739541160594  0.0174951994879454 
                262                 273                 230                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0194376952447067  0.0201068974293713   0.020628078817734  0.0217065004041104 
                154                 259                 328                 450 
 0.0217617659308621  0.0217782577393808  0.0220403022670025  0.0227412415488629 
                247                 273                  83                  90 
 0.0230348401957961  0.0230622919638611   0.023341049382716  0.0236710130391174 
                281                 127                 439                 216 
 0.0237923576063446  0.0239011309315612  0.0242544731610338  0.0243264977885002 
                475                 227                  61                 307 
 0.0243547800799709  0.0246305418719212   0.024763619990995  0.0247737017627442 
                139                 109                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253881661770877 
                268                 166                 153                 203 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0279437271150511   0.027964785085448 
                200                 243                 234                  65 
  0.028270509977827  0.0286692340607617   0.028899183763512  0.0292200966996006 
                 65                 290                 135                 174 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299939283545841 
                 95                 247                 176                 228 
 0.0300982800982801  0.0301942222947609  0.0308211473565804  0.0312345066931086 
                375                 169                 114                 168 
  0.031377415351888  0.0315893385982231  0.0320326150262085  0.0320665083135392 
                254                  97                  56                  58 
 0.0325693606755127  0.0343403607911324  0.0347459003084916  0.0349115972430327 
                166                 235                 203                 291 
 0.0350253807106599    0.03547209181012  0.0354838709677419  0.0356612184249629 
                 53                  45                 176                  76 
 0.0359856057576969  0.0362541993281075  0.0367789392179636  0.0383953168044077 
                242                 183                 148                 231 
 0.0391606080634501  0.0412642669007902    0.04203013481364  0.0422836752899197 
                237                 198                 384                 292 
 0.0426995042379658  0.0433547898523287  0.0433574207893274  0.0435029049171036 
                197                 312                 209                 177 
 0.0436484634957917   0.044525215810995  0.0461725394896719  0.0467409948542024 
                227                 226                 125                 221 
 0.0467555821969129  0.0468945766959012  0.0470430107526882   0.047542735042735 
                221                 226                  76                 302 
 0.0475452196382429  0.0477157360406091  0.0482456140350877  0.0496535796766744 
                 62                  64                  35                  37 
 0.0502816607552681  0.0509113764927718  0.0516417910447761   0.052053981907163 
                509                 224                 154                 167 
 0.0522693757168606  0.0526235972095845  0.0527306967984934   0.053840499816244 
                165                 204                  78                 239 
 0.0541623127830024  0.0542635658914729  0.0572625698324022   0.058057312988463 
                225                 149                 208                 454 
 0.0605700712589074  0.0605714285714286   0.061569416498994  0.0636079249217935 
                 27                 150                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0649717514124294  0.0654566518632941 
                 88                 157                 333                 179 
 0.0659246575342466  0.0664614270191959  0.0691703391454302  0.0710715061943056 
                214                 140                 148                 125 
 0.0731810490693739  0.0734780628510703   0.074849349825563  0.0753043119455333 
                147                 227                 127                 176 
 0.0755026672137874              0.0765  0.0771307365985345   0.077457264957265 
                 72                 206                 144                 178 
 0.0775623268698061  0.0795717592592593  0.0799757649197213  0.0808438558669541 
                214                 146                 126                 174 
 0.0850873264666368  0.0879211175020542  0.0926889714993804  0.0946155169447789 
                181                 110                 144                 163 
 0.0951444859445646  0.0964175143741707  0.0990077653149267   0.102649006622517 
                209                 149                 185                 184 
   0.10270393092479   0.103008945513689   0.108005366726297   0.108166470357283 
                157                 167                 171                 170 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> ##########################
> #Germany
> ##########################
> 
> country="Germany (until 1990 former territory of the FRG)"

> cntry<-"DE"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844  0.0128509045539613 
                 49                  41                  54                 411 
 0.0135111727005023  0.0135225216646034  0.0140120610145442    0.01517663563321 
                293                 298                 469                 226 
  0.015375854214123  0.0163260512097721  0.0164333536214242  0.0165365653245686 
                 40                 261                  56                 338 
   0.01692628480314  0.0172651069685975  0.0172739541160594  0.0174951994879454 
                262                 273                 230                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0194376952447067  0.0201068974293713   0.020628078817734  0.0217065004041104 
                154                 259                 328                 450 
 0.0217617659308621  0.0217782577393808  0.0220403022670025  0.0227412415488629 
                247                 273                  83                  90 
 0.0230348401957961  0.0230622919638611   0.023341049382716  0.0236710130391174 
                281                 127                 439                 216 
 0.0237923576063446  0.0239011309315612  0.0242544731610338  0.0243264977885002 
                475                 227                  61                 307 
 0.0243547800799709  0.0246305418719212   0.024763619990995  0.0247737017627442 
                139                 109                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253881661770877 
                268                 166                 153                 203 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0279437271150511   0.027964785085448 
                200                 243                 234                  65 
 0.0282313475062647   0.028270509977827  0.0286692340607617   0.028899183763512 
                337                  65                 290                 135 
 0.0292200966996006   0.029377657518361  0.0295730980205104  0.0298372513562387 
                174                  95                 247                 176 
 0.0299939283545841  0.0300982800982801  0.0301942222947609  0.0308211473565804 
                228                 375                 169                 114 
 0.0312345066931086   0.031377415351888  0.0315893385982231  0.0320326150262085 
                168                 254                  97                  56 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0343403607911324 
                 58                 166                 139                 235 
 0.0347459003084916  0.0349115972430327  0.0350253807106599    0.03547209181012 
                203                 291                  53                  45 
 0.0354838709677419  0.0356612184249629  0.0359856057576969  0.0362541993281075 
                176                  76                 242                 183 
 0.0367789392179636  0.0373705538045925  0.0383953168044077  0.0391606080634501 
                148                  13                 231                 237 
 0.0412642669007902    0.04203013481364  0.0422836752899197  0.0426995042379658 
                198                 384                 292                 197 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0436484634957917   0.044525215810995  0.0461725394896719  0.0467409948542024 
                227                 226                 125                 221 
 0.0467555821969129  0.0468945766959012  0.0470430107526882   0.047542735042735 
                221                 226                  76                 302 
 0.0475452196382429  0.0477157360406091  0.0482456140350877  0.0496535796766744 
                 62                  64                  35                  37 
 0.0502816607552681  0.0509113764927718  0.0516417910447761   0.052053981907163 
                509                 224                 154                 167 
 0.0522693757168606  0.0526235972095845  0.0527306967984934   0.053840499816244 
                165                 204                  78                 239 
 0.0541623127830024  0.0542635658914729  0.0572625698324022  0.0579365729738589 
                225                 149                 208                 327 
  0.058057312988463  0.0605700712589074  0.0605714285714286   0.061569416498994 
                454                  27                 150                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0649717514124294 
                341                  88                 157                 333 
 0.0654566518632941  0.0659246575342466  0.0664614270191959  0.0691703391454302 
                179                 214                 140                 148 
 0.0710715061943056  0.0731810490693739  0.0734780628510703  0.0739031028851388 
                125                 147                 227                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874              0.0765 
                127                 176                  72                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061  0.0795717592592593 
                144                 178                 214                 146 
 0.0799757649197213  0.0808438558669541  0.0850873264666368  0.0879211175020542 
                126                 174                 181                 110 
 0.0913471466923659  0.0926889714993804  0.0946155169447789  0.0951444859445646 
                224                 144                 163                 209 
 0.0961078221438468  0.0964175143741707  0.0990077653149267   0.100058147336405 
                 80                 149                 185                 399 
  0.102649006622517    0.10270393092479   0.103008945513689   0.108005366726297 
                184                 157                 167                 171 
  0.108166470357283   0.126307739369838 
                170                 204 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844  0.0128509045539613 
                 49                  41                  54                 411 
 0.0135111727005023  0.0135225216646034  0.0140120610145442    0.01517663563321 
                293                 298                 469                 226 
  0.015375854214123  0.0163260512097721  0.0164333536214242  0.0165365653245686 
                 40                 261                  56                 338 
   0.01692628480314  0.0172651069685975  0.0172739541160594  0.0174951994879454 
                262                 273                 230                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0194376952447067  0.0201068974293713   0.020628078817734  0.0217065004041104 
                154                 259                 328                 450 
 0.0217617659308621  0.0217782577393808  0.0220403022670025  0.0227412415488629 
                247                 273                  83                  90 
 0.0230348401957961  0.0230622919638611   0.023341049382716  0.0236710130391174 
                281                 127                 439                 216 
 0.0237923576063446  0.0239011309315612  0.0242544731610338  0.0243264977885002 
                475                 227                  61                 307 
 0.0243547800799709  0.0246305418719212   0.024763619990995  0.0247737017627442 
                139                 109                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253881661770877 
                268                 166                 153                 203 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0279437271150511   0.027964785085448 
                200                 243                 234                  65 
 0.0282313475062647   0.028270509977827  0.0286692340607617   0.028899183763512 
                337                  65                 290                 135 
 0.0292200966996006   0.029377657518361  0.0295730980205104  0.0298372513562387 
                174                  95                 247                 176 
 0.0299939283545841  0.0300982800982801  0.0301942222947609  0.0308211473565804 
                228                 375                 169                 114 
 0.0312345066931086   0.031377415351888  0.0315893385982231  0.0320326150262085 
                168                 254                  97                  56 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0343403607911324 
                 58                 166                 139                 235 
 0.0347459003084916  0.0349115972430327  0.0350253807106599  0.0351973182995581 
                203                 291                  53                 349 
   0.03547209181012  0.0354838709677419  0.0356612184249629  0.0359856057576969 
                 45                 176                  76                 242 
 0.0362541993281075  0.0367789392179636  0.0373705538045925  0.0383953168044077 
                183                 148                  13                 231 
 0.0391606080634501  0.0408432147562582  0.0412642669007902    0.04203013481364 
                237                   9                 198                 384 
 0.0422836752899197  0.0426995042379658  0.0431638211196045  0.0433547898523287 
                292                 197                 221                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0436484634957917 
                209                 515                 177                 227 
  0.044525215810995  0.0461725394896719  0.0467409948542024  0.0467555821969129 
                226                 125                 221                 221 
 0.0468945766959012  0.0470430107526882   0.047542735042735  0.0475452196382429 
                226                  76                 302                  62 
 0.0477157360406091  0.0482456140350877  0.0496535796766744  0.0502816607552681 
                 64                  35                  37                 509 
 0.0509113764927718  0.0516417910447761   0.052053981907163  0.0522693757168606 
                224                 154                 167                 165 
 0.0526235972095845  0.0527306967984934   0.053186119873817   0.053840499816244 
                204                  78                 493                 239 
 0.0541623127830024  0.0542635658914729  0.0572625698324022  0.0579365729738589 
                225                 149                 208                 327 
  0.058057312988463  0.0605700712589074  0.0605714285714286   0.061569416498994 
                454                  27                 150                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0649717514124294 
                341                  88                 157                 333 
 0.0654566518632941  0.0659246575342466  0.0664614270191959  0.0691703391454302 
                179                 214                 140                 148 
 0.0710715061943056  0.0731810490693739  0.0734780628510703  0.0739031028851388 
                125                 147                 227                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874              0.0765 
                127                 176                  72                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061   0.077792732166891 
                144                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0808438558669541  0.0850873264666368 
                146                 126                 174                 181 
 0.0879211175020542  0.0913471466923659  0.0919729186043997  0.0926889714993804 
                110                 224                 315                 144 
 0.0946155169447789  0.0951444859445646  0.0961078221438468  0.0964175143741707 
                163                 209                  80                 149 
 0.0990077653149267   0.100058147336405   0.102649006622517    0.10270393092479 
                185                 399                 184                 157 
  0.103008945513689   0.108005366726297   0.108166470357283   0.110151036178433 
                167                 171                 170                 190 
  0.114229765013055   0.126307739369838   0.136729555838747   0.154871196536584 
                 73                 204                 383                 210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844  0.0116639598405433 
                 49                  41                  54                 365 
 0.0128509045539613  0.0135111727005023  0.0135225216646034  0.0140120610145442 
                411                 293                 298                 469 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163260512097721 
                226                  40                 132                 261 
 0.0164333536214242  0.0165365653245686    0.01692628480314  0.0172651069685975 
                 56                 338                 262                 273 
 0.0172739541160594  0.0174951994879454  0.0177547118273696  0.0178593575592211 
                230                 463                 164                 227 
 0.0180937818552497  0.0182452374563992  0.0194376952447067  0.0201068974293713 
                156                 211                 154                 259 
  0.020628078817734  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                328                 450                 247                 273 
 0.0220403022670025  0.0225645183083367  0.0227412415488629  0.0230348401957961 
                 83                 548                  90                 281 
 0.0230622919638611   0.023341049382716  0.0236710130391174  0.0237923576063446 
                127                 439                 216                 475 
 0.0239011309315612  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                227                  61                 307                 139 
 0.0246305418719212   0.024763619990995  0.0247737017627442  0.0248179120582681 
                109                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877  0.0256829707181417 
                166                 153                 203                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0279437271150511   0.027964785085448  0.0282313475062647 
                243                 234                  65                 337 
  0.028270509977827  0.0286692340607617   0.028899183763512  0.0292200966996006 
                 65                 290                 135                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299939283545841  0.0300982800982801  0.0301942222947609  0.0308211473565804 
                228                 375                 169                 114 
 0.0312345066931086   0.031377415351888  0.0315893385982231  0.0320326150262085 
                168                 254                  97                  56 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0343403607911324 
                 58                 166                 139                 235 
 0.0347459003084916  0.0349115972430327  0.0350253807106599  0.0351973182995581 
                203                 291                  53                 349 
   0.03547209181012  0.0354838709677419  0.0356612184249629  0.0359856057576969 
                 45                 176                  76                 242 
 0.0362541993281075  0.0367789392179636  0.0373705538045925  0.0383953168044077 
                183                 148                  13                 231 
 0.0391606080634501  0.0408432147562582  0.0412642669007902    0.04203013481364 
                237                   9                 198                 384 
 0.0422836752899197  0.0426995042379658  0.0431638211196045  0.0433547898523287 
                292                 197                 221                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0436484634957917 
                209                 515                 177                 227 
 0.0439361466262656  0.0442073170731707   0.044525215810995  0.0445749030296677 
                181                  90                 226                 328 
 0.0458288578589331  0.0461725394896719  0.0467409948542024  0.0467555821969129 
                427                 125                 221                 221 
 0.0468945766959012  0.0470430107526882   0.047542735042735  0.0475452196382429 
                226                  76                 302                  62 
 0.0477157360406091  0.0482456140350877  0.0496535796766744  0.0502816607552681 
                 64                  35                  37                 509 
 0.0509113764927718  0.0516417910447761   0.052053981907163  0.0522693757168606 
                224                 154                 167                 165 
 0.0526235972095845  0.0527306967984934   0.053186119873817   0.053840499816244 
                204                  78                 493                 239 
 0.0541623127830024  0.0542635658914729  0.0572625698324022  0.0579365729738589 
                225                 149                 208                 327 
  0.058057312988463  0.0605700712589074  0.0605714285714286  0.0606246548444499 
                454                  27                 150                 210 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0649717514124294  0.0654566518632941  0.0659246575342466  0.0664614270191959 
                333                 179                 214                 140 
 0.0691703391454302  0.0710715061943056  0.0731810490693739  0.0734780628510703 
                148                 125                 147                 227 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0808438558669541 
                292                 146                 126                 174 
 0.0850873264666368  0.0879211175020542  0.0913471466923659  0.0919729186043997 
                181                 110                 224                 315 
 0.0926889714993804  0.0946155169447789  0.0951444859445646  0.0961078221438468 
                144                 163                 209                  80 
 0.0964175143741707  0.0990077653149267   0.100058147336405   0.102649006622517 
                149                 185                 399                 184 
   0.10270393092479   0.103008945513689   0.108005366726297   0.108166470357283 
                157                 167                 171                 170 
  0.110151036178433   0.114229765013055   0.126307739369838   0.136729555838747 
                190                  73                 204                 383 
  0.154871196536584 
                210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0116639598405433  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                365                 411                 293                 298 
 0.0140120610145442   0.014044436416185  0.0146315889810314    0.01517663563321 
                469                 146                 487                 226 
  0.015375854214123  0.0154054184575264  0.0163260512097721  0.0164333536214242 
                 40                 132                 261                  56 
 0.0165365653245686    0.01692628480314  0.0172651069685975  0.0172739541160594 
                338                 262                 273                 230 
 0.0174951994879454  0.0177547118273696  0.0178593575592211  0.0180937818552497 
                463                 164                 227                 156 
 0.0182452374563992  0.0194376952447067  0.0201068974293713   0.020628078817734 
                211                 154                 259                 328 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0220403022670025 
                450                 247                 273                  83 
 0.0225645183083367  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                548                  90                 281                 127 
  0.023341049382716  0.0236710130391174  0.0237923576063446  0.0239011309315612 
                439                 216                 475                 227 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877  0.0256829707181417 
                166                 153                 203                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0279437271150511   0.027964785085448  0.0282313475062647 
                243                 234                  65                 337 
  0.028270509977827  0.0286692340607617   0.028899183763512  0.0292200966996006 
                 65                 290                 135                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299939283545841  0.0300982800982801  0.0301942222947609  0.0308211473565804 
                228                 375                 169                 114 
 0.0312345066931086   0.031377415351888  0.0315893385982231  0.0320326150262085 
                168                 254                  97                  56 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0332120109190173 
                 58                 166                 139                 353 
 0.0343403607911324  0.0345168698109875  0.0347459003084916  0.0349115972430327 
                235                 180                 203                 291 
 0.0350253807106599  0.0351973182995581  0.0353873479983604    0.03547209181012 
                 53                 349                  69                  45 
 0.0354838709677419  0.0356612184249629  0.0359856057576969  0.0362541993281075 
                176                  76                 242                 183 
 0.0367789392179636  0.0373638098364692  0.0373705538045925  0.0383953168044077 
                148                 334                  13                 231 
 0.0391606080634501  0.0408432147562582  0.0412642669007902    0.04203013481364 
                237                   9                 198                 384 
 0.0422836752899197  0.0426995042379658  0.0431638211196045  0.0433547898523287 
                292                 197                 221                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0436484634957917 
                209                 515                 177                 227 
 0.0439361466262656  0.0442073170731707   0.044525215810995  0.0445749030296677 
                181                  90                 226                 328 
 0.0458288578589331  0.0461725394896719  0.0467409948542024  0.0467555821969129 
                427                 125                 221                 221 
 0.0468945766959012  0.0470430107526882   0.047542735042735  0.0475452196382429 
                226                  76                 302                  62 
 0.0477157360406091  0.0482456140350877  0.0496535796766744  0.0502816607552681 
                 64                  35                  37                 509 
 0.0509113764927718  0.0516417910447761   0.052053981907163  0.0522693757168606 
                224                 154                 167                 165 
 0.0526235972095845  0.0527306967984934   0.053186119873817   0.053840499816244 
                204                  78                 493                 239 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0572625698324022 
                225                 149                 181                 208 
 0.0579365729738589   0.058057312988463  0.0605700712589074  0.0605714285714286 
                327                 454                  27                 150 
 0.0606246548444499   0.061569416498994  0.0636079249217935  0.0641271581255138 
                210                 111                 341                  88 
 0.0643896976483763  0.0649717514124294  0.0654566518632941  0.0659246575342466 
                157                 333                 179                 214 
 0.0664614270191959  0.0691703391454302  0.0710715061943056  0.0731810490693739 
                140                 148                 125                 147 
 0.0734780628510703  0.0739031028851388   0.074849349825563  0.0753043119455333 
                227                 356                 127                 176 
 0.0755026672137874              0.0765  0.0771307365985345   0.077457264957265 
                 72                 206                 144                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0799757649197213 
                214                 292                 146                 126 
 0.0808438558669541  0.0850873264666368  0.0879211175020542  0.0913471466923659 
                174                 181                 110                 224 
 0.0919729186043997  0.0926889714993804  0.0946155169447789  0.0951444859445646 
                315                 144                 163                 209 
 0.0961078221438468  0.0964175143741707  0.0990077653149267   0.100058147336405 
                 80                 149                 185                 399 
  0.102649006622517    0.10270393092479   0.103008945513689   0.108005366726297 
                184                 157                 167                 171 
  0.108166470357283   0.110151036178433   0.114229765013055   0.126307739369838 
                170                 190                  73                 204 
  0.136729555838747   0.154871196536584 
                383                 210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163260512097721 
                226                  40                 132                 261 
 0.0164333536214242  0.0164978360593875  0.0165365653245686  0.0166853053008276 
                 56                 544                 338                 151 
   0.01692628480314  0.0172651069685975  0.0172739541160594  0.0174951994879454 
                262                 273                 230                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0194376952447067  0.0201068974293713   0.020628078817734  0.0217065004041104 
                154                 259                 328                 450 
 0.0217617659308621  0.0217782577393808  0.0220403022670025  0.0225645183083367 
                247                 273                  83                 548 
 0.0227412415488629  0.0230348401957961  0.0230622919638611   0.023341049382716 
                 90                 281                 127                 439 
 0.0236710130391174  0.0237923576063446  0.0239011309315612  0.0242544731610338 
                216                 475                 227                  61 
 0.0243264977885002  0.0243547800799709  0.0246305418719212  0.0247417579018989 
                307                 139                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0253881661770877   0.025439388079584  0.0256829707181417 
                153                 203                 323                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0279437271150511   0.027964785085448  0.0282313475062647 
                243                 234                  65                 337 
  0.028270509977827  0.0286692340607617   0.028899183763512  0.0292200966996006 
                 65                 290                 135                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299939283545841  0.0300982800982801  0.0301942222947609  0.0308211473565804 
                228                 375                 169                 114 
 0.0312345066931086   0.031377415351888  0.0315893385982231  0.0320326150262085 
                168                 254                  97                  56 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0332120109190173 
                 58                 166                 139                 353 
 0.0343403607911324  0.0345168698109875  0.0347459003084916  0.0348890414092885 
                235                 180                 203                 205 
 0.0349115972430327  0.0350253807106599  0.0351497282512167  0.0351973182995581 
                291                  53                 406                 349 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356612184249629 
                 69                  45                 176                  76 
 0.0359856057576969  0.0361134995700774  0.0362541993281075  0.0367789392179636 
                242                  70                 183                 148 
 0.0369817341324224  0.0373638098364692  0.0373705538045925  0.0383953168044077 
                313                 334                  13                 231 
 0.0391606080634501  0.0408432147562582  0.0412642669007902    0.04203013481364 
                237                   9                 198                 384 
 0.0422836752899197  0.0426995042379658  0.0431638211196045  0.0433547898523287 
                292                 197                 221                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0436484634957917 
                209                 515                 177                 227 
 0.0439361466262656  0.0442073170731707   0.044525215810995  0.0445749030296677 
                181                  90                 226                 328 
 0.0458288578589331  0.0461725394896719  0.0467409948542024  0.0467555821969129 
                427                 125                 221                 221 
 0.0468945766959012  0.0470430107526882   0.047542735042735  0.0475452196382429 
                226                  76                 302                  62 
 0.0477157360406091  0.0482456140350877  0.0496535796766744  0.0502816607552681 
                 64                  35                  37                 509 
 0.0509113764927718  0.0516417910447761   0.052053981907163  0.0522693757168606 
                224                 154                 167                 165 
 0.0526235972095845  0.0527306967984934   0.053186119873817   0.053840499816244 
                204                  78                 493                 239 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0572625698324022  0.0579365729738589   0.058057312988463  0.0605700712589074 
                208                 327                 454                  27 
 0.0605714285714286  0.0606246548444499   0.061569416498994  0.0636079249217935 
                150                 210                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0649717514124294  0.0654566518632941 
                 88                 157                 333                 179 
 0.0659246575342466  0.0664614270191959  0.0691703391454302  0.0710715061943056 
                214                 140                 148                 125 
 0.0731810490693739  0.0734780628510703  0.0739031028851388   0.074849349825563 
                147                 227                 356                 127 
 0.0753043119455333  0.0755026672137874              0.0765  0.0771307365985345 
                176                  72                 206                 144 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0808438558669541  0.0850873264666368  0.0879211175020542 
                126                 174                 181                 110 
 0.0913471466923659  0.0919729186043997  0.0926889714993804  0.0946155169447789 
                224                 315                 144                 163 
 0.0951444859445646  0.0961078221438468  0.0964175143741707  0.0990077653149267 
                209                  80                 149                 185 
  0.100058147336405   0.102649006622517    0.10270393092479   0.103008945513689 
                399                 184                 157                 167 
  0.108005366726297   0.108166470357283   0.110151036178433   0.114229765013055 
                171                 170                 190                  73 
  0.126307739369838   0.136729555838747   0.154871196536584 
                204                 383                 210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                261                  56                 544                 338 
 0.0166853053008276    0.01692628480314  0.0172651069685975  0.0172739541160594 
                151                 262                 273                 230 
 0.0174951994879454  0.0177547118273696  0.0178593575592211  0.0180937818552497 
                463                 164                 227                 156 
 0.0182452374563992  0.0194376952447067  0.0199234423280911  0.0201068974293713 
                211                 154                 511                 259 
  0.020628078817734  0.0207115701072462  0.0217065004041104  0.0217617659308621 
                328                 150                 450                 247 
 0.0217782577393808  0.0220403022670025  0.0225645183083367  0.0227412415488629 
                273                  83                 548                  90 
 0.0230348401957961  0.0230622919638611   0.023341049382716  0.0236710130391174 
                281                 127                 439                 216 
 0.0237923576063446  0.0239011309315612  0.0242544731610338  0.0243264977885002 
                475                 227                  61                 307 
 0.0243547800799709  0.0246305418719212  0.0247417579018989   0.024763619990995 
                139                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0253881661770877   0.025439388079584  0.0256829707181417  0.0257910706545297 
                203                 323                 187                 259 
  0.026079869600652  0.0261760937213985  0.0264531848242255  0.0266724967205947 
                213                 306                 166                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0286692340607617   0.028899183763512  0.0292200966996006  0.0292865871644684 
                290                 135                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299939283545841 
                 95                 247                 176                 228 
 0.0300982800982801  0.0301942222947609  0.0308211473565804  0.0312345066931086 
                375                 169                 114                 168 
  0.031377415351888  0.0315893385982231  0.0320326150262085  0.0320665083135392 
                254                  97                  56                  58 
 0.0325693606755127  0.0331766657450926  0.0332120109190173  0.0343403607911324 
                166                 139                 353                 235 
 0.0345168698109875  0.0347459003084916  0.0348890414092885  0.0349115972430327 
                180                 203                 205                 291 
 0.0350253807106599  0.0351497282512167  0.0351973182995581  0.0353873479983604 
                 53                 406                 349                  69 
   0.03547209181012  0.0354838709677419  0.0356612184249629  0.0359856057576969 
                 45                 176                  76                 242 
 0.0361134995700774  0.0362541993281075  0.0367789392179636  0.0369817341324224 
                 70                 183                 148                 313 
 0.0373638098364692  0.0373705538045925  0.0383953168044077  0.0384615384615385 
                334                  13                 231                 348 
 0.0391606080634501  0.0408432147562582  0.0412642669007902    0.04203013481364 
                237                   9                 198                 384 
 0.0422836752899197  0.0426995042379658  0.0431638211196045  0.0433547898523287 
                292                 197                 221                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0436484634957917 
                209                 515                 177                 227 
 0.0439361466262656  0.0442073170731707   0.044525215810995  0.0445749030296677 
                181                  90                 226                 328 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0467409948542024 
                 53                 427                 125                 221 
 0.0467555821969129  0.0468945766959012  0.0470430107526882   0.047542735042735 
                221                 226                  76                 302 
 0.0475452196382429  0.0477157360406091  0.0482456140350877  0.0496535796766744 
                 62                  64                  35                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513616687062777 
                509                 224                 194                 343 
 0.0516417910447761   0.052053981907163  0.0522693757168606  0.0526235972095845 
                154                 167                 165                 204 
 0.0527306967984934   0.053186119873817   0.053840499816244  0.0541623127830024 
                 78                 493                 239                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0572625698324022 
                149                 181                 239                 208 
 0.0577124691399777  0.0579365729738589   0.058057312988463  0.0605700712589074 
                443                 327                 454                  27 
 0.0605714285714286  0.0606246548444499   0.061569416498994  0.0636079249217935 
                150                 210                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0649717514124294  0.0654566518632941 
                 88                 157                 333                 179 
 0.0659246575342466  0.0664614270191959  0.0691703391454302  0.0710715061943056 
                214                 140                 148                 125 
 0.0731810490693739  0.0734780628510703  0.0739031028851388   0.074849349825563 
                147                 227                 356                 127 
 0.0753043119455333  0.0755026672137874              0.0765  0.0771307365985345 
                176                  72                 206                 144 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0808438558669541  0.0850873264666368  0.0879211175020542 
                126                 174                 181                 110 
 0.0913471466923659  0.0919729186043997  0.0926889714993804  0.0941611024293223 
                224                 315                 144                 197 
 0.0946155169447789  0.0951444859445646  0.0961078221438468  0.0964175143741707 
                163                 209                  80                 149 
 0.0990077653149267   0.100058147336405   0.102649006622517    0.10270393092479 
                185                 399                 184                 157 
  0.103008945513689   0.108005366726297   0.108166470357283   0.110151036178433 
                167                 171                 170                 190 
  0.114229765013055   0.126307739369838   0.136729555838747   0.154871196536584 
                 73                 204                 383                 210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                261                  56                 544                 338 
 0.0166853053008276    0.01692628480314  0.0172651069685975  0.0172739541160594 
                151                 262                 273                 230 
 0.0174939864421605  0.0174951994879454  0.0177547118273696  0.0178593575592211 
                536                 463                 164                 227 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0194376952447067 
                156                 211                 587                 154 
 0.0194924196145943  0.0199234423280911  0.0201068974293713   0.020628078817734 
                206                 511                 259                 328 
 0.0207115701072462  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                150                 450                 247                 273 
 0.0220403022670025  0.0225645183083367  0.0227412415488629  0.0230348401957961 
                 83                 548                  90                 281 
 0.0230622919638611   0.023341049382716  0.0236710130391174  0.0237923576063446 
                127                 439                 216                 475 
 0.0239011309315612  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                227                  61                 307                 139 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253881661770877 
                268                 166                 153                 203 
  0.025439388079584  0.0256829707181417  0.0257910706545297   0.026079869600652 
                323                 187                 259                 213 
 0.0261760937213985  0.0264531848242255  0.0266724967205947  0.0267139027192646 
                306                 166                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0279437271150511 
                175                 200                 243                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0286692340607617 
                 65                 337                  65                 290 
  0.028899183763512  0.0292200966996006  0.0292865871644684   0.029377657518361 
                135                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0299939283545841  0.0300982800982801 
                247                 176                 228                 375 
 0.0301942222947609  0.0308211473565804  0.0312345066931086   0.031377415351888 
                169                 114                 168                 254 
 0.0315893385982231  0.0320326150262085  0.0320665083135392  0.0325693606755127 
                 97                  56                  58                 166 
 0.0331766657450926  0.0332120109190173  0.0343403607911324  0.0345168698109875 
                139                 353                 235                 180 
 0.0347459003084916  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                203                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353873479983604    0.03547209181012 
                406                 349                  69                  45 
 0.0354838709677419  0.0356612184249629  0.0359856057576969   0.036105476673428 
                176                  76                 242                 363 
 0.0361134995700774  0.0362541993281075  0.0367789392179636  0.0369817341324224 
                 70                 183                 148                 313 
 0.0373638098364692  0.0373705538045925  0.0383953168044077  0.0384615384615385 
                334                  13                 231                 348 
 0.0391606080634501  0.0408432147562582  0.0412642669007902    0.04203013481364 
                237                   9                 198                 384 
 0.0422836752899197  0.0426995042379658  0.0431638211196045  0.0433547898523287 
                292                 197                 221                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0436484634957917 
                209                 515                 177                 227 
 0.0439361466262656  0.0442073170731707   0.044525215810995  0.0445749030296677 
                181                  90                 226                 328 
 0.0452668098463572  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                 54                  53                 427                 125 
 0.0467409948542024  0.0467555821969129  0.0468945766959012  0.0470430107526882 
                221                 221                 226                  76 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0482456140350877  0.0485338331185819  0.0496535796766744  0.0502816607552681 
                 35                 165                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513616687062777  0.0516417910447761 
                224                 194                 343                 154 
  0.052053981907163  0.0522119900389417  0.0522693757168606  0.0526235972095845 
                167                 394                 165                 204 
 0.0527306967984934   0.053186119873817   0.053840499816244  0.0541623127830024 
                 78                 493                 239                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0572625698324022 
                149                 181                 239                 208 
 0.0577124691399777  0.0579365729738589   0.058057312988463  0.0605700712589074 
                443                 327                 454                  27 
 0.0605714285714286  0.0606246548444499   0.061569416498994  0.0636079249217935 
                150                 210                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0649717514124294  0.0654566518632941 
                 88                 157                 333                 179 
 0.0659246575342466  0.0664614270191959  0.0691703391454302  0.0710715061943056 
                214                 140                 148                 125 
 0.0731810490693739  0.0734780628510703  0.0739031028851388   0.074849349825563 
                147                 227                 356                 127 
 0.0753043119455333  0.0755026672137874              0.0765  0.0771307365985345 
                176                  72                 206                 144 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0808438558669541  0.0845114315664221  0.0850873264666368 
                126                 174                 171                 181 
 0.0879211175020542  0.0913471466923659  0.0919729186043997  0.0926889714993804 
                110                 224                 315                 144 
 0.0941611024293223  0.0946155169447789  0.0951444859445646  0.0961078221438468 
                197                 163                 209                  80 
 0.0964175143741707  0.0990077653149267   0.100058147336405   0.102649006622517 
                149                 185                 399                 184 
   0.10270393092479   0.103008945513689   0.108005366726297   0.108166470357283 
                157                 167                 171                 170 
  0.110151036178433   0.114229765013055   0.126307739369838   0.136729555838747 
                190                  73                 204                 383 
  0.154871196536584 
                210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ####################################################
> 
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> ##########################
> #Denmark
> ##########################
> 
> country="Denmark"

> cntry<-"DK"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                261                  56                 544                 338 
 0.0166853053008276    0.01692628480314  0.0172651069685975  0.0172739541160594 
                151                 262                 273                 230 
 0.0174939864421605  0.0174951994879454  0.0177547118273696  0.0178593575592211 
                536                 463                 164                 227 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0194376952447067 
                156                 211                 587                 154 
 0.0194924196145943  0.0199234423280911  0.0201068974293713   0.020628078817734 
                206                 511                 259                 328 
 0.0207115701072462  0.0208385638965604  0.0217065004041104  0.0217617659308621 
                150                 180                 450                 247 
 0.0217782577393808  0.0220403022670025  0.0225645183083367  0.0227412415488629 
                273                  83                 548                  90 
 0.0230348401957961  0.0230622919638611   0.023341049382716  0.0236710130391174 
                281                 127                 439                 216 
 0.0237923576063446  0.0239011309315612  0.0242544731610338  0.0243264977885002 
                475                 227                  61                 307 
 0.0243547800799709  0.0246305418719212  0.0247417579018989   0.024763619990995 
                139                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0253881661770877   0.025439388079584  0.0256829707181417  0.0257910706545297 
                203                 323                 187                 259 
  0.026079869600652  0.0261760937213985  0.0264531848242255  0.0266724967205947 
                213                 306                 166                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617   0.028899183763512  0.0292200966996006 
                289                 290                 135                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299939283545841  0.0300982800982801  0.0301942222947609  0.0308211473565804 
                228                 375                 169                 114 
 0.0312345066931086   0.031377415351888  0.0315893385982231  0.0320326150262085 
                168                 254                  97                  56 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0332120109190173 
                 58                 166                 139                 353 
 0.0343403607911324  0.0345168698109875  0.0347459003084916  0.0348890414092885 
                235                 180                 203                 205 
 0.0349115972430327  0.0350253807106599  0.0351497282512167  0.0351973182995581 
                291                  53                 406                 349 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362541993281075  0.0367789392179636  0.0369817341324224  0.0373638098364692 
                183                 148                 313                 334 
 0.0373705538045925  0.0383953168044077  0.0384615384615385  0.0391606080634501 
                 13                 231                 348                 237 
 0.0403430749682338  0.0408432147562582  0.0412642669007902    0.04203013481364 
                185                   9                 198                 384 
 0.0422836752899197  0.0423121387283237  0.0426995042379658  0.0431638211196045 
                292                 187                 197                 221 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0436484634957917  0.0439361466262656  0.0442073170731707   0.044525215810995 
                227                 181                  90                 226 
 0.0445749030296677  0.0452668098463572  0.0458015267175573  0.0458288578589331 
                328                  54                  53                 427 
 0.0461725394896719  0.0467409948542024  0.0467555821969129  0.0468945766959012 
                125                 221                 221                 226 
 0.0470430107526882  0.0473145307359627   0.047542735042735  0.0475452196382429 
                 76                 358                 302                  62 
 0.0477157360406091  0.0482456140350877  0.0485338331185819  0.0492055356227576 
                 64                  35                 165                  98 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0512921525370312 
                 37                 509                 224                 194 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0526235972095845  0.0527306967984934   0.053186119873817 
                165                 204                  78                 493 
  0.053840499816244  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                239                 225                 149                 181 
 0.0551325007614986  0.0572625698324022  0.0577124691399777  0.0579365729738589 
                239                 208                 443                 327 
  0.058057312988463  0.0605700712589074  0.0605714285714286  0.0606246548444499 
                454                  27                 150                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0649717514124294  0.0654566518632941  0.0659246575342466 
                157                 333                 179                 214 
 0.0664614270191959  0.0691703391454302  0.0710715061943056  0.0731810490693739 
                140                 148                 125                 147 
 0.0734780628510703  0.0739031028851388   0.074849349825563  0.0753043119455333 
                227                 356                 127                 176 
 0.0755026672137874              0.0765  0.0771307365985345   0.077457264957265 
                 72                 206                 144                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0799757649197213 
                214                 292                 146                 126 
 0.0808438558669541  0.0845114315664221  0.0850873264666368  0.0879211175020542 
                174                 171                 181                 110 
 0.0913471466923659  0.0919729186043997  0.0926889714993804  0.0941611024293223 
                224                 315                 144                 197 
 0.0946155169447789  0.0951444859445646  0.0961078221438468  0.0964175143741707 
                163                 209                  80                 149 
 0.0990077653149267   0.100058147336405   0.102649006622517    0.10270393092479 
                185                 399                 184                 157 
  0.103008945513689   0.108005366726297   0.108166470357283   0.110151036178433 
                167                 171                 170                 190 
  0.114229765013055   0.126307739369838   0.136729555838747   0.154871196536584 
                 73                 204                 383                 210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                261                  56                 544                 338 
 0.0166853053008276    0.01692628480314  0.0172651069685975  0.0172739541160594 
                151                 262                 273                 230 
 0.0174939864421605  0.0174951994879454  0.0177547118273696  0.0178593575592211 
                536                 463                 164                 227 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0194376952447067 
                156                 211                 587                 154 
 0.0194924196145943  0.0199234423280911  0.0201068974293713  0.0206237424547284 
                206                 511                 259                 141 
  0.020628078817734  0.0207115701072462  0.0208385638965604  0.0217065004041104 
                328                 150                 180                 450 
 0.0217617659308621  0.0217782577393808  0.0220403022670025  0.0225645183083367 
                247                 273                  83                 548 
 0.0227412415488629  0.0230348401957961  0.0230622919638611   0.023341049382716 
                 90                 281                 127                 439 
 0.0235011990407674  0.0236710130391174  0.0237923576063446  0.0239011309315612 
                209                 216                 475                 227 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877   0.025439388079584 
                166                 153                 203                 323 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0279437271150511   0.027964785085448 
                200                 243                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0292200966996006  0.0292865871644684   0.029377657518361 
                135                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0299939283545841  0.0300982800982801 
                247                 176                 228                 375 
 0.0301942222947609  0.0308211473565804  0.0312345066931086   0.031377415351888 
                169                 114                 168                 254 
 0.0315893385982231  0.0320326150262085  0.0320665083135392  0.0325693606755127 
                 97                  56                  58                 166 
 0.0331766657450926  0.0332120109190173  0.0343403607911324  0.0345168698109875 
                139                 353                 235                 180 
 0.0347459003084916  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                203                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353873479983604    0.03547209181012 
                406                 349                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362541993281075  0.0367789392179636 
                363                  70                 183                 148 
 0.0369817341324224  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                313                 334                  13                 260 
 0.0383953168044077  0.0384615384615385  0.0391606080634501  0.0403430749682338 
                231                 348                 237                 185 
 0.0408432147562582  0.0412642669007902    0.04203013481364  0.0422836752899197 
                  9                 198                 384                 292 
 0.0423121387283237  0.0426995042379658  0.0431638211196045  0.0433547898523287 
                187                 197                 221                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0436484634957917 
                209                 515                 177                 227 
 0.0437311002558735  0.0439361466262656  0.0442073170731707   0.044525215810995 
                225                 181                  90                 226 
 0.0445749030296677  0.0452668098463572  0.0458015267175573  0.0458288578589331 
                328                  54                  53                 427 
 0.0461725394896719  0.0467409948542024  0.0467555821969129  0.0468945766959012 
                125                 221                 221                 226 
 0.0470430107526882  0.0473145307359627   0.047542735042735  0.0475452196382429 
                 76                 358                 302                  62 
 0.0477157360406091  0.0479256080114449  0.0482456140350877  0.0483870967741935 
                 64                 140                  35                 132 
 0.0485338331185819  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                165                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513616687062777 
                509                 224                 194                 343 
 0.0516417910447761   0.052053981907163  0.0522119900389417  0.0522693757168606 
                154                 167                 394                 165 
 0.0526235972095845  0.0527306967984934   0.053186119873817   0.053840499816244 
                204                  78                 493                 239 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0605700712589074  0.0605714285714286  0.0606246548444499  0.0610859728506787 
                 27                 150                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0649717514124294  0.0654566518632941  0.0659246575342466  0.0664614270191959 
                333                 179                 214                 140 
 0.0691703391454302  0.0710715061943056  0.0731810490693739  0.0734780628510703 
                148                 125                 147                 227 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0808438558669541 
                292                 146                 126                 174 
 0.0845114315664221  0.0850873264666368  0.0850877192982456  0.0879211175020542 
                171                 181                 166                 110 
 0.0913471466923659  0.0919729186043997  0.0926889714993804  0.0941611024293223 
                224                 315                 144                 197 
 0.0946155169447789  0.0951444859445646  0.0961078221438468  0.0964175143741707 
                163                 209                  80                 149 
 0.0990077653149267   0.100058147336405   0.102649006622517    0.10270393092479 
                185                 399                 184                 157 
  0.103008945513689   0.108005366726297   0.108166470357283   0.110151036178433 
                167                 171                 170                 190 
  0.114229765013055   0.126307739369838   0.136729555838747   0.154871196536584 
                 73                 204                 383                 210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                261                  56                 544                 338 
 0.0166853053008276    0.01692628480314  0.0172651069685975  0.0172739541160594 
                151                 262                 273                 230 
 0.0174939864421605  0.0174951994879454  0.0177547118273696  0.0178593575592211 
                536                 463                 164                 227 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0199234423280911  0.0201068974293713 
                154                 206                 511                 259 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0208385638965604 
                141                 328                 150                 180 
  0.020919175911252  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                151                 450                 247                 273 
 0.0220403022670025  0.0225645183083367  0.0227412415488629  0.0230348401957961 
                 83                 548                  90                 281 
 0.0230622919638611  0.0231803430690774   0.023341049382716  0.0235011990407674 
                127                 199                 439                 209 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0239011309315612 
                216                 266                 475                 227 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877   0.025439388079584 
                166                 153                 203                 323 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0279437271150511   0.027964785085448 
                200                 243                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0292200966996006  0.0292865871644684   0.029377657518361 
                135                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0299939283545841  0.0300982800982801 
                247                 176                 228                 375 
 0.0301942222947609  0.0308211473565804  0.0312345066931086   0.031377415351888 
                169                 114                 168                 254 
 0.0315893385982231  0.0320326150262085  0.0320665083135392  0.0325693606755127 
                 97                  56                  58                 166 
 0.0331766657450926  0.0332120109190173  0.0340782122905028  0.0343403607911324 
                139                 353                  90                 235 
 0.0345168698109875  0.0347459003084916  0.0348890414092885  0.0349115972430327 
                180                 203                 205                 291 
 0.0350253807106599  0.0351497282512167  0.0351973182995581  0.0353873479983604 
                 53                 406                 349                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362541993281075 
                242                 363                  70                 183 
 0.0366379310344828  0.0367789392179636  0.0369817341324224  0.0373638098364692 
                119                 148                 313                 334 
 0.0373705538045925  0.0375362566114997  0.0383953168044077  0.0384615384615385 
                 13                 260                 231                 348 
 0.0391606080634501  0.0403430749682338  0.0408432147562582  0.0412642669007902 
                237                 185                   9                 198 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0426995042379658 
                384                 292                 187                 197 
 0.0431638211196045  0.0433547898523287  0.0433574207893274  0.0434699883302045 
                221                 312                 209                 515 
 0.0435029049171036  0.0435547734271887  0.0436484634957917  0.0437311002558735 
                177                 176                 227                 225 
 0.0439361466262656  0.0442073170731707   0.044525215810995  0.0445749030296677 
                181                  90                 226                 328 
 0.0452668098463572  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                 54                  53                 427                 125 
 0.0467409948542024  0.0467555821969129  0.0468945766959012  0.0470430107526882 
                221                 221                 226                  76 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                140                 149                  35                 132 
 0.0485338331185819  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                165                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513616687062777 
                509                 224                 194                 343 
 0.0516417910447761   0.052053981907163  0.0522119900389417  0.0522693757168606 
                154                 167                 394                 165 
 0.0526235972095845  0.0527306967984934   0.053186119873817   0.053840499816244 
                204                  78                 493                 239 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0605700712589074  0.0605714285714286  0.0606246548444499  0.0610859728506787 
                 27                 150                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0649717514124294  0.0654566518632941  0.0659246575342466  0.0664614270191959 
                333                 179                 214                 140 
 0.0691703391454302  0.0710715061943056  0.0731810490693739  0.0734780628510703 
                148                 125                 147                 227 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0808438558669541 
                292                 146                 126                 174 
 0.0845114315664221  0.0850873264666368  0.0850877192982456  0.0879211175020542 
                171                 181                 166                 110 
 0.0913471466923659  0.0919729186043997  0.0926889714993804  0.0941611024293223 
                224                 315                 144                 197 
 0.0946155169447789  0.0951444859445646  0.0961078221438468  0.0964175143741707 
                163                 209                  80                 149 
 0.0990077653149267   0.100058147336405   0.102649006622517    0.10270393092479 
                185                 399                 184                 157 
  0.103008945513689   0.108005366726297   0.108166470357283   0.110151036178433 
                167                 171                 170                 190 
  0.114229765013055   0.126307739369838   0.136729555838747   0.154871196536584 
                 73                 204                 383                 210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0186451971127152  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                587                 242                 154                 206 
 0.0198854061341422  0.0199234423280911  0.0201068974293713  0.0206237424547284 
                159                 511                 259                 141 
  0.020628078817734  0.0207115701072462  0.0208385638965604   0.020919175911252 
                328                 150                 180                 151 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0220403022670025 
                450                 247                 273                  83 
 0.0225645183083367  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                548                  90                 281                 127 
 0.0231803430690774   0.023341049382716  0.0235011990407674  0.0236710130391174 
                199                 439                 209                 216 
 0.0237315875613748  0.0237923576063446  0.0239011309315612  0.0239206534422404 
                266                 475                 227                 163 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877   0.025439388079584 
                166                 153                 203                 323 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0279437271150511   0.027964785085448 
                200                 243                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0292200966996006  0.0292865871644684   0.029377657518361 
                135                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0299939283545841  0.0300982800982801 
                247                 176                 228                 375 
 0.0301942222947609  0.0308211473565804  0.0312345066931086   0.031352533722202 
                169                 114                 168                 157 
  0.031377415351888  0.0315893385982231  0.0320326150262085  0.0320665083135392 
                254                  97                  56                  58 
 0.0325693606755127  0.0331766657450926  0.0332120109190173  0.0340782122905028 
                166                 139                 353                  90 
 0.0343403607911324  0.0345168698109875  0.0347459003084916  0.0348890414092885 
                235                 180                 203                 205 
 0.0349115972430327  0.0350253807106599  0.0351497282512167  0.0351973182995581 
                291                  53                 406                 349 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0366379310344828  0.0367789392179636 
                223                 183                 119                 148 
 0.0369817341324224  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                313                 334                  13                 260 
 0.0381717729784028  0.0383953168044077  0.0384615384615385  0.0391606080634501 
                 89                 231                 348                 237 
 0.0403430749682338  0.0408432147562582  0.0412642669007902    0.04203013481364 
                185                   9                 198                 384 
 0.0422836752899197  0.0423121387283237  0.0426995042379658  0.0431638211196045 
                292                 187                 197                 221 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0435547734271887  0.0436484634957917  0.0437311002558735  0.0439361466262656 
                176                 227                 225                 181 
 0.0442073170731707   0.044525215810995  0.0445749030296677  0.0452668098463572 
                 90                 226                 328                  54 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0467409948542024 
                 53                 427                 125                 221 
 0.0467555821969129  0.0468945766959012  0.0470430107526882  0.0473145307359627 
                221                 226                  76                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513616687062777  0.0516417910447761 
                224                 194                 343                 154 
  0.052053981907163  0.0522119900389417  0.0522693757168606  0.0526235972095845 
                167                 394                 165                 204 
 0.0527306967984934   0.053186119873817   0.053840499816244  0.0541623127830024 
                 78                 493                 239                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0572625698324022 
                149                 181                 239                 208 
 0.0577124691399777  0.0579365729738589   0.058057312988463  0.0601947477131897 
                443                 327                 454                 127 
 0.0605700712589074  0.0605714285714286  0.0606246548444499  0.0610859728506787 
                 27                 150                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0649717514124294  0.0654566518632941  0.0659246575342466  0.0664614270191959 
                333                 179                 214                 140 
 0.0691703391454302  0.0710715061943056  0.0731810490693739  0.0734780628510703 
                148                 125                 147                 227 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0808438558669541 
                292                 146                 126                 174 
 0.0845114315664221  0.0850873264666368  0.0850877192982456  0.0879211175020542 
                171                 181                 166                 110 
 0.0913471466923659  0.0919729186043997  0.0926889714993804  0.0941611024293223 
                224                 315                 144                 197 
 0.0946155169447789  0.0951444859445646  0.0961078221438468  0.0964175143741707 
                163                 209                  80                 149 
 0.0990077653149267   0.100058147336405   0.102649006622517    0.10270393092479 
                185                 399                 184                 157 
  0.103008945513689   0.108005366726297   0.108166470357283   0.110151036178433 
                167                 171                 170                 190 
  0.114229765013055   0.126307739369838   0.136729555838747   0.154871196536584 
                 73                 204                 383                 210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0186451971127152  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                587                 242                 154                 206 
 0.0198854061341422  0.0199234423280911  0.0201068974293713  0.0206237424547284 
                159                 511                 259                 141 
  0.020628078817734  0.0207115701072462  0.0208385638965604   0.020919175911252 
                328                 150                 180                 151 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0220403022670025 
                450                 247                 273                  83 
 0.0225645183083367  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                548                  90                 281                 127 
 0.0231803430690774   0.023341049382716  0.0235011990407674  0.0236710130391174 
                199                 439                 209                 216 
 0.0237315875613748  0.0237923576063446  0.0239011309315612  0.0239206534422404 
                266                 475                 227                 163 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877   0.025439388079584 
                166                 153                 203                 323 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0279437271150511   0.027964785085448 
                200                 243                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0292200966996006  0.0292865871644684   0.029377657518361 
                135                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0299939283545841  0.0300982800982801 
                247                 176                 228                 375 
  0.030188679245283  0.0301942222947609  0.0308211473565804  0.0312345066931086 
                245                 169                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0332120109190173 
                 58                 166                 139                 353 
 0.0333333333333333  0.0340782122905028  0.0343403607911324  0.0345168698109875 
                142                  90                 235                 180 
 0.0347459003084916  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                203                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353873479983604    0.03547209181012 
                406                 349                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0366379310344828  0.0367789392179636  0.0369127516778524  0.0369817341324224 
                119                 148                  26                 313 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0381717729784028 
                334                  13                 260                  89 
 0.0383953168044077  0.0384615384615385  0.0391606080634501  0.0403430749682338 
                231                 348                 237                 185 
 0.0408432147562582  0.0412642669007902  0.0412961567445365    0.04203013481364 
                  9                 198                 298                 384 
 0.0422836752899197  0.0423121387283237  0.0426995042379658  0.0431638211196045 
                292                 187                 197                 221 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0435547734271887  0.0436484634957917  0.0437311002558735  0.0439361466262656 
                176                 227                 225                 181 
 0.0442073170731707   0.044525215810995  0.0445749030296677  0.0452668098463572 
                 90                 226                 328                  54 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0467409948542024 
                 53                 427                 125                 221 
 0.0467555821969129  0.0468945766959012  0.0470430107526882  0.0473145307359627 
                221                 226                  76                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513616687062777  0.0516417910447761 
                224                 194                 343                 154 
  0.052053981907163  0.0522119900389417  0.0522693757168606  0.0526235972095845 
                167                 394                 165                 204 
 0.0527306967984934   0.053186119873817   0.053840499816244  0.0541623127830024 
                 78                 493                 239                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0572625698324022 
                149                 181                 239                 208 
 0.0577124691399777  0.0579365729738589   0.058057312988463  0.0601947477131897 
                443                 327                 454                 127 
 0.0605700712589074  0.0605714285714286  0.0606246548444499  0.0610859728506787 
                 27                 150                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0664614270191959  0.0683411214953271  0.0691703391454302  0.0710715061943056 
                140                 282                 148                 125 
 0.0731810490693739  0.0734780628510703  0.0739031028851388   0.074849349825563 
                147                 227                 356                 127 
 0.0753043119455333  0.0755026672137874              0.0765  0.0771307365985345 
                176                  72                 206                 144 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0808438558669541  0.0845114315664221  0.0850873264666368 
                126                 174                 171                 181 
 0.0850877192982456  0.0879211175020542  0.0913471466923659  0.0919729186043997 
                166                 110                 224                 315 
 0.0926889714993804  0.0941611024293223  0.0944649446494465  0.0946155169447789 
                144                 197                 140                 163 
 0.0951444859445646  0.0961078221438468  0.0964175143741707  0.0990077653149267 
                209                  80                 149                 185 
  0.100058147336405   0.102649006622517    0.10270393092479   0.103008945513689 
                399                 184                 157                 167 
  0.108005366726297   0.108166470357283   0.110151036178433   0.114229765013055 
                171                 170                 190                  73 
  0.121081745543946   0.125267338832875   0.126307739369838   0.136729555838747 
                102                 175                 204                 383 
  0.154871196536584 
                210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0186451971127152  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                587                 242                 154                 206 
 0.0198854061341422  0.0199234423280911  0.0201068974293713  0.0206237424547284 
                159                 511                 259                 141 
  0.020628078817734  0.0207115701072462  0.0208385638965604   0.020919175911252 
                328                 150                 180                 151 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0220403022670025 
                450                 247                 273                  83 
 0.0225645183083367  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                548                  90                 281                 127 
 0.0231803430690774   0.023341049382716  0.0235011990407674  0.0236710130391174 
                199                 439                 209                 216 
 0.0237315875613748  0.0237923576063446  0.0239011309315612  0.0239206534422404 
                266                 475                 227                 163 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877   0.025439388079584 
                166                 153                 203                 323 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0279437271150511   0.027964785085448 
                200                 243                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0292200966996006  0.0292865871644684   0.029377657518361 
                135                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0299939283545841  0.0300218340611354 
                247                 176                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609  0.0308211473565804 
                375                 245                 169                 114 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0315893385982231 
                168                 157                 254                  97 
 0.0320326150262085  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 56                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0340782122905028  0.0343403607911324 
                353                 142                  90                 235 
 0.0345168698109875  0.0347459003084916  0.0348890414092885  0.0349115972430327 
                180                 203                 205                 291 
 0.0350253807106599  0.0351497282512167  0.0351973182995581  0.0353873479983604 
                 53                 406                 349                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0366379310344828  0.0367789392179636  0.0369127516778524 
                183                 119                 148                  26 
 0.0369817341324224  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                313                 334                  13                 260 
 0.0381717729784028  0.0383953168044077  0.0384615384615385  0.0391606080634501 
                 89                 231                 348                 237 
 0.0403430749682338  0.0408432147562582  0.0412642669007902  0.0412961567445365 
                185                   9                 198                 298 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0426995042379658 
                384                 292                 187                 197 
 0.0431638211196045  0.0433547898523287  0.0433574207893274  0.0434699883302045 
                221                 312                 209                 515 
 0.0435029049171036  0.0435547734271887  0.0436484634957917  0.0437311002558735 
                177                 176                 227                 225 
 0.0439361466262656  0.0442073170731707   0.044525215810995  0.0445749030296677 
                181                  90                 226                 328 
 0.0452668098463572  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                 54                  53                 427                 125 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0468945766959012 
                161                 221                 221                 226 
 0.0470430107526882  0.0473145307359627   0.047542735042735  0.0475452196382429 
                 76                 358                 302                  62 
 0.0477157360406091  0.0479256080114449  0.0482120051085568  0.0482456140350877 
                 64                 140                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0492055356227576  0.0494997367035282 
                132                 165                  98                 106 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0512921525370312 
                 37                 509                 224                 194 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0526235972095845  0.0527306967984934   0.053186119873817 
                165                 204                  78                 493 
  0.053840499816244  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                239                 225                 149                 181 
 0.0551325007614986  0.0572625698324022  0.0577124691399777  0.0579365729738589 
                239                 208                 443                 327 
  0.058057312988463  0.0601947477131897  0.0605700712589074  0.0605714285714286 
                454                 127                  27                 150 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0649717514124294  0.0654566518632941 
                 88                 157                 333                 179 
 0.0659246575342466   0.065989847715736  0.0664614270191959  0.0681222707423581 
                214                 104                 140                 163 
 0.0683411214953271  0.0691703391454302  0.0704392560348239  0.0710715061943056 
                282                 148                 135                 125 
 0.0731810490693739  0.0734780628510703  0.0739031028851388   0.074849349825563 
                147                 227                 356                 127 
 0.0753043119455333  0.0755026672137874              0.0765  0.0771307365985345 
                176                  72                 206                 144 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0808438558669541   0.081692573402418  0.0819262038774234 
                126                 174                 331                  81 
 0.0845114315664221  0.0850873264666368  0.0850877192982456  0.0879211175020542 
                171                 181                 166                 110 
 0.0913471466923659  0.0919729186043997  0.0926889714993804  0.0941611024293223 
                224                 315                 144                 197 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0961078221438468 
                140                 163                 209                  80 
 0.0964175143741707  0.0990077653149267   0.100058147336405   0.102649006622517 
                149                 185                 399                 184 
   0.10270393092479   0.103008945513689   0.108005366726297   0.108166470357283 
                157                 167                 171                 170 
  0.110151036178433   0.114229765013055   0.119464797706276   0.121081745543946 
                190                  73                 199                 102 
  0.125267338832875   0.126307739369838   0.136729555838747   0.154871196536584 
                175                 204                 383                 210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0186451971127152  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                587                 242                 154                 206 
 0.0198854061341422  0.0199234423280911  0.0201068974293713  0.0206237424547284 
                159                 511                 259                 141 
  0.020628078817734  0.0207115701072462  0.0208385638965604   0.020919175911252 
                328                 150                 180                 151 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0220403022670025 
                450                 247                 273                  83 
 0.0225645183083367  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                548                  90                 281                 127 
 0.0231803430690774   0.023341049382716  0.0235011990407674  0.0236710130391174 
                199                 439                 209                 216 
 0.0237315875613748  0.0237923576063446  0.0239011309315612  0.0239206534422404 
                266                 475                 227                 163 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877   0.025439388079584 
                166                 153                 203                 323 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0272490757223059  0.0279437271150511 
                200                 243                 394                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617   0.028899183763512  0.0292200966996006  0.0292865871644684 
                290                 135                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299939283545841 
                 95                 247                 176                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
 0.0308211473565804  0.0312345066931086   0.031352533722202   0.031377415351888 
                114                 168                 157                 254 
 0.0315893385982231  0.0320326150262085  0.0320665083135392  0.0325693606755127 
                 97                  56                  58                 166 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0340782122905028 
                139                 353                 142                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348890414092885  0.0349115972430327  0.0350253807106599  0.0351497282512167 
                205                 291                  53                 406 
 0.0351973182995581  0.0353873479983604    0.03547209181012  0.0354838709677419 
                349                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0366379310344828 
                 70                 223                 183                 119 
 0.0367789392179636  0.0369127516778524  0.0369817341324224  0.0373638098364692 
                148                  26                 313                 334 
 0.0373705538045925  0.0375362566114997  0.0381717729784028  0.0383953168044077 
                 13                 260                  89                 231 
 0.0384615384615385  0.0391606080634501  0.0403430749682338  0.0408432147562582 
                348                 237                 185                   9 
 0.0412642669007902  0.0412961567445365    0.04203013481364  0.0422836752899197 
                198                 298                 384                 292 
 0.0423121387283237  0.0426995042379658  0.0431638211196045  0.0433547898523287 
                187                 197                 221                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                209                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0439361466262656  0.0441482715535194 
                227                 225                 181                 137 
 0.0442073170731707   0.044525215810995  0.0445749030296677  0.0452668098463572 
                 90                 226                 328                  54 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0463450600379187 
                 53                 427                 125                 161 
 0.0467409948542024  0.0467555821969129  0.0468945766959012  0.0470430107526882 
                221                 221                 226                  76 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                140                 149                  35                 132 
 0.0485338331185819  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                165                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513616687062777 
                509                 224                 194                 343 
 0.0516417910447761   0.052053981907163  0.0522119900389417  0.0522693757168606 
                154                 167                 394                 165 
 0.0526235972095845  0.0527306967984934   0.053186119873817   0.053840499816244 
                204                  78                 493                 239 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0601947477131897  0.0605700712589074  0.0605714285714286  0.0606246548444499 
                127                  27                 150                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0649717514124294  0.0654566518632941  0.0659246575342466 
                157                 333                 179                 214 
  0.065989847715736  0.0664614270191959  0.0676933491284481   0.067850348763475 
                104                 140                 256                  74 
 0.0681222707423581  0.0683411214953271  0.0691703391454302   0.069882777276826 
                163                 282                 148                 107 
 0.0704392560348239  0.0710715061943056  0.0731810490693739  0.0734780628510703 
                135                 125                 147                 227 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0808438558669541 
                292                 146                 126                 174 
  0.081692573402418  0.0819262038774234  0.0845114315664221  0.0850873264666368 
                331                  81                 171                 181 
 0.0850877192982456  0.0879211175020542  0.0913471466923659  0.0919729186043997 
                166                 110                 224                 315 
 0.0926889714993804  0.0941611024293223  0.0944649446494465  0.0946155169447789 
                144                 197                 140                 163 
 0.0951444859445646  0.0961078221438468  0.0964175143741707  0.0990077653149267 
                209                  80                 149                 185 
  0.100058147336405   0.102649006622517    0.10270393092479   0.102815564694717 
                399                 184                 157                 134 
  0.103008945513689   0.108005366726297   0.108166470357283   0.110151036178433 
                167                 171                 170                 190 
  0.114229765013055   0.119464797706276   0.121081745543946   0.125267338832875 
                 73                 199                 102                 175 
  0.126307739369838   0.136729555838747   0.154871196536584 
                204                 383                 210 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> #By country
> country="Spain"

> cntry<-"ES"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0186451971127152  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                587                 242                 154                 206 
 0.0198854061341422  0.0199234423280911  0.0201068974293713  0.0206237424547284 
                159                 511                 259                 141 
  0.020628078817734  0.0207115701072462  0.0208385638965604   0.020919175911252 
                328                 150                 180                 151 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0220403022670025 
                450                 247                 273                  83 
 0.0225645183083367  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                548                  90                 281                 127 
 0.0231803430690774   0.023341049382716  0.0235011990407674  0.0236710130391174 
                199                 439                 209                 216 
 0.0237315875613748  0.0237923576063446  0.0239011309315612  0.0239206534422404 
                266                 475                 227                 163 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877   0.025439388079584 
                166                 153                 203                 323 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0272490757223059  0.0279437271150511 
                200                 243                 394                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617   0.028899183763512  0.0290282520956225  0.0292200966996006 
                290                 135                  61                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609  0.0308211473565804  0.0312345066931086   0.031352533722202 
                169                 114                 168                 157 
  0.031377415351888  0.0315893385982231  0.0320326150262085  0.0320665083135392 
                254                  97                  56                  58 
 0.0325693606755127  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                166                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0343403607911324  0.0344104070499371 
                122                  90                 235                 183 
 0.0345168698109875  0.0347459003084916  0.0348890414092885  0.0349115972430327 
                180                 203                 205                 291 
 0.0350253807106599  0.0351497282512167  0.0351973182995581  0.0353873479983604 
                 53                 406                 349                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0366379310344828  0.0367789392179636  0.0369127516778524 
                183                 119                 148                  26 
 0.0369817341324224  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                313                 334                  13                 260 
 0.0381717729784028  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                 89                 123                 231                 348 
 0.0391606080634501  0.0403430749682338  0.0408432147562582  0.0412642669007902 
                237                 185                   9                 198 
 0.0412961567445365    0.04203013481364  0.0422836752899197  0.0423121387283237 
                298                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0433547898523287  0.0433574207893274 
                197                 221                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                225                 181                 137                  90 
  0.044525215810995  0.0445749030296677  0.0452668098463572  0.0458015267175573 
                226                 328                  54                  53 
 0.0458288578589331  0.0461725394896719  0.0463450600379187  0.0467409948542024 
                427                 125                 161                 221 
 0.0467555821969129  0.0468945766959012  0.0470430107526882  0.0473145307359627 
                221                 226                  76                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513616687062777  0.0516417910447761 
                224                 194                 343                 154 
  0.052053981907163  0.0522119900389417  0.0522693757168606  0.0526235972095845 
                167                 394                 165                 204 
 0.0527306967984934   0.053186119873817   0.053840499816244  0.0541623127830024 
                 78                 493                 239                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0572625698324022 
                149                 181                 239                 208 
 0.0577124691399777  0.0579365729738589   0.058057312988463  0.0601947477131897 
                443                 327                 454                 127 
 0.0605700712589074  0.0605714285714286  0.0606246548444499  0.0610859728506787 
                 27                 150                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068   0.066402490801019  0.0664614270191959  0.0676933491284481 
                154                 108                 140                 256 
  0.067850348763475  0.0681222707423581  0.0683411214953271  0.0691703391454302 
                 74                 163                 282                 148 
  0.069882777276826  0.0704392560348239  0.0710715061943056  0.0731810490693739 
                107                 135                 125                 147 
 0.0734780628510703  0.0739031028851388   0.074849349825563  0.0753043119455333 
                227                 356                 127                 176 
 0.0755026672137874  0.0761834556584725              0.0765  0.0771307365985345 
                 72                 238                 206                 144 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0808438558669541   0.081692573402418  0.0819262038774234 
                126                 174                 331                  81 
 0.0845114315664221  0.0850873264666368  0.0850877192982456  0.0879211175020542 
                171                 181                 166                 110 
 0.0907393359397794  0.0913471466923659  0.0919729186043997  0.0926889714993804 
                 78                 224                 315                 144 
 0.0941611024293223  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                197                 140                 163                 209 
 0.0961078221438468  0.0964175143741707  0.0990077653149267   0.100058147336405 
                 80                 149                 185                 399 
  0.102649006622517    0.10270393092479   0.102815564694717   0.103008945513689 
                184                 157                 134                 167 
  0.108005366726297   0.108166470357283   0.110151036178433   0.114229765013055 
                171                 170                 190                  73 
  0.114525835974502   0.119464797706276   0.121081745543946   0.125267338832875 
                198                 199                 102                 175 
  0.126307739369838   0.136729555838747   0.154871196536584   0.185637891520244 
                204                 383                 210                 262 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0128509045539613  0.0135111727005023 
                444                 365                 411                 293 
 0.0135225216646034  0.0140120610145442   0.014044436416185  0.0146315889810314 
                298                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0186451971127152  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                587                 242                 154                 206 
 0.0198854061341422  0.0199234423280911  0.0201068974293713  0.0206237424547284 
                159                 511                 259                 141 
  0.020628078817734  0.0207115701072462  0.0208385638965604   0.020919175911252 
                328                 150                 180                 151 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0220403022670025 
                450                 247                 273                  83 
 0.0225645183083367  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                548                  90                 281                 127 
 0.0231803430690774   0.023341049382716  0.0235011990407674  0.0236710130391174 
                199                 439                 209                 216 
 0.0237315875613748  0.0237923576063446  0.0239011309315612  0.0239206534422404 
                266                 475                 227                 163 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877   0.025439388079584 
                166                 153                 203                 323 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0272490757223059  0.0279437271150511 
                200                 243                 394                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617   0.028899183763512  0.0290282520956225  0.0292200966996006 
                290                 135                  61                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609  0.0308211473565804  0.0312345066931086   0.031352533722202 
                169                 114                 168                 157 
  0.031377415351888  0.0315893385982231  0.0320326150262085  0.0320470415288497 
                254                  97                  56                  66 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0332120109190173 
                 58                 166                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0343403607911324 
                142                 122                  90                 235 
 0.0344104070499371  0.0345168698109875  0.0347459003084916  0.0348890414092885 
                183                 180                 203                 205 
 0.0349115972430327  0.0350253807106599  0.0351497282512167  0.0351973182995581 
                291                  53                 406                 349 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0366379310344828  0.0367789392179636 
                223                 183                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0373638098364692  0.0373705538045925 
                 26                 313                 334                  13 
 0.0375362566114997  0.0381717729784028  0.0382320029839612  0.0383953168044077 
                260                  89                 123                 231 
 0.0384615384615385  0.0386931402066889  0.0391606080634501  0.0403430749682338 
                348                 178                 237                 185 
 0.0408432147562582  0.0412642669007902  0.0412961567445365    0.04203013481364 
                  9                 198                 298                 384 
 0.0422836752899197  0.0423121387283237  0.0426995042379658  0.0431638211196045 
                292                 187                 197                 221 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0435547734271887  0.0436484634957917  0.0437311002558735  0.0439361466262656 
                176                 227                 225                 181 
 0.0441482715535194  0.0442073170731707   0.044525215810995  0.0445749030296677 
                137                  90                 226                 328 
 0.0452668098463572  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                 54                  53                 427                 125 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0468945766959012  0.0470430107526882  0.0473145307359627   0.047542735042735 
                226                  76                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449  0.0482120051085568 
                 62                  64                 140                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0492055356227576 
                 35                 132                 165                  98 
 0.0494997367035282  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                106                  37                 509                 224 
 0.0512921525370312  0.0513616687062777  0.0516417910447761   0.052053981907163 
                194                 343                 154                 167 
 0.0522119900389417  0.0522693757168606  0.0526235972095845  0.0527306967984934 
                394                 165                 204                  78 
  0.053186119873817   0.053840499816244  0.0541623127830024  0.0542635658914729 
                493                 239                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0572625698324022  0.0577124691399777 
                181                 239                 208                 443 
 0.0579365729738589   0.058057312988463  0.0601947477131897  0.0605700712589074 
                327                 454                 127                  27 
 0.0605714285714286  0.0606246548444499  0.0610859728506787   0.061569416498994 
                150                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0649717514124294 
                341                  88                 157                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
  0.066402490801019  0.0664614270191959  0.0676933491284481   0.067850348763475 
                108                 140                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0691703391454302 
                189                 163                 282                 148 
  0.069882777276826  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                107                 135                  76                 125 
 0.0731810490693739  0.0734780628510703  0.0739031028851388   0.074849349825563 
                147                 227                 356                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0761834556584725 
                176                  72                 180                 238 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0808438558669541 
                292                 146                 126                 174 
  0.081692573402418  0.0819262038774234  0.0845114315664221  0.0850873264666368 
                331                  81                 171                 181 
 0.0850877192982456  0.0879211175020542  0.0907393359397794  0.0913471466923659 
                166                 110                  78                 224 
 0.0919729186043997  0.0926889714993804  0.0931930062807673  0.0941611024293223 
                315                 144                  55                 197 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0961078221438468 
                140                 163                 209                  80 
 0.0964175143741707  0.0990077653149267   0.100058147336405   0.102649006622517 
                149                 185                 399                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.108005366726297 
                157                 134                 167                 171 
  0.108166470357283   0.110151036178433   0.114229765013055   0.114525835974502 
                170                 190                  73                 198 
  0.117099936431463   0.119464797706276   0.121081745543946   0.125267338832875 
                174                 199                 102                 175 
  0.126307739369838   0.136729555838747   0.154871196536584   0.181258488003622 
                204                 383                 210                 190 
  0.185637891520244 
                262 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0118375774260151  0.0128509045539613 
                444                 365                 120                 411 
 0.0135111727005023  0.0135225216646034  0.0140120610145442   0.014044436416185 
                293                 298                 469                 146 
 0.0146315889810314    0.01517663563321   0.015375854214123  0.0154054184575264 
                487                 226                  40                 132 
 0.0163213683449771  0.0163260512097721  0.0164196123147092  0.0164333536214242 
                467                 261                 226                  56 
 0.0164978360593875  0.0165365653245686  0.0166853053008276  0.0166950069562529 
                544                 338                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172739541160594  0.0174939864421605 
                262                 273                 230                 536 
 0.0174951994879454  0.0177547118273696  0.0178593575592211  0.0180937818552497 
                463                 164                 227                 156 
 0.0182452374563992  0.0186451971127152  0.0188848920863309  0.0194376952447067 
                211                 587                 242                 154 
 0.0194924196145943  0.0198854061341422  0.0199234423280911  0.0201068974293713 
                206                 159                 511                 259 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0208385638965604 
                141                 328                 150                 180 
  0.020919175911252  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                151                 450                 247                 273 
 0.0220403022670025  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                 83                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
  0.023341049382716  0.0235011990407674  0.0236710130391174  0.0237315875613748 
                439                 209                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253881661770877   0.025439388079584 
                166                 153                 203                 323 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                166                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0272490757223059  0.0279437271150511 
                200                 243                 394                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617   0.028899183763512  0.0290282520956225  0.0292200966996006 
                290                 135                  61                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609  0.0308211473565804  0.0312345066931086   0.031352533722202 
                169                 114                 168                 157 
  0.031377415351888  0.0315893385982231  0.0320326150262085  0.0320470415288497 
                254                  97                  56                  66 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0332120109190173 
                 58                 166                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0343403607911324 
                142                 122                  90                 235 
 0.0344104070499371  0.0345168698109875  0.0347459003084916  0.0348244147157191 
                183                 180                 203                 152 
 0.0348890414092885  0.0349115972430327  0.0350253807106599  0.0351497282512167 
                205                 291                  53                 406 
 0.0351973182995581  0.0353873479983604    0.03547209181012  0.0354838709677419 
                349                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0366379310344828 
                 70                 223                 183                 119 
 0.0367789392179636  0.0369127516778524  0.0369817341324224  0.0373638098364692 
                148                  26                 313                 334 
 0.0373705538045925  0.0375362566114997  0.0381717729784028  0.0382320029839612 
                 13                 260                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0391606080634501 
                231                 348                 178                 237 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412642669007902 
                185                   9                 120                 198 
 0.0412961567445365    0.04203013481364  0.0422836752899197  0.0423121387283237 
                298                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0433547898523287  0.0433574207893274 
                197                 221                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                225                 181                 137                  90 
  0.044525215810995  0.0445749030296677  0.0452668098463572  0.0458015267175573 
                226                 328                  54                  53 
 0.0458288578589331  0.0461725394896719  0.0463034418891804  0.0463450600379187 
                427                 125                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
 0.0470430107526882  0.0473145307359627   0.047542735042735  0.0475452196382429 
                 76                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0492055356227576 
                 35                 132                 165                  98 
 0.0494997367035282  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                106                  37                 509                 224 
 0.0512921525370312  0.0513616687062777  0.0516417910447761   0.052053981907163 
                194                 343                 154                 167 
 0.0522119900389417  0.0522693757168606  0.0526235972095845  0.0527306967984934 
                394                 165                 204                  78 
  0.053186119873817   0.053840499816244  0.0541623127830024  0.0542635658914729 
                493                 239                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0572625698324022  0.0577124691399777 
                181                 239                 208                 443 
 0.0579365729738589   0.058057312988463  0.0601947477131897  0.0605700712589074 
                327                 454                 127                  27 
 0.0605714285714286  0.0606246548444499  0.0610859728506787   0.061569416498994 
                150                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0649717514124294 
                341                  88                 157                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
  0.066402490801019  0.0664614270191959  0.0676933491284481   0.067850348763475 
                108                 140                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0691703391454302 
                189                 163                 282                 148 
  0.069882777276826  0.0701461377870564  0.0704392560348239  0.0705556460811471 
                107                 287                 135                  76 
 0.0710715061943056  0.0731810490693739  0.0734780628510703  0.0739031028851388 
                125                 147                 227                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761834556584725              0.0765  0.0771307365985345   0.077457264957265 
                238                 206                 144                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0799757649197213 
                214                 292                 146                 126 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0845114315664221 
                174                 331                  81                 171 
 0.0850873264666368  0.0850877192982456  0.0879211175020542  0.0907393359397794 
                181                 166                 110                  78 
 0.0913471466923659  0.0919729186043997  0.0926889714993804  0.0931930062807673 
                224                 315                 144                  55 
 0.0941611024293223  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                197                 140                 163                 209 
 0.0961078221438468  0.0964175143741707  0.0990077653149267   0.100058147336405 
                 80                 149                 185                 399 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.108005366726297   0.108166470357283   0.110151036178433 
                167                 171                 170                 190 
  0.114229765013055   0.114525835974502   0.117099936431463   0.119464797706276 
                 73                 198                 174                 199 
  0.121081745543946   0.125267338832875   0.126307739369838   0.136729555838747 
                102                 175                 204                 383 
  0.154871196536584   0.181258488003622   0.185637891520244 
                210                 190                 262 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0111783249552697  0.0116639598405433  0.0118375774260151  0.0128509045539613 
                444                 365                 120                 411 
 0.0135111727005023  0.0135225216646034  0.0139675349188373  0.0140120610145442 
                293                 298                 227                 469 
  0.014044436416185  0.0146315889810314    0.01517663563321   0.015375854214123 
                146                 487                 226                  40 
 0.0154054184575264  0.0163213683449771  0.0163260512097721  0.0164196123147092 
                132                 467                 261                 226 
 0.0164333536214242  0.0164978360593875  0.0165365653245686  0.0166853053008276 
                 56                 544                 338                 151 
 0.0166950069562529    0.01692628480314  0.0172651069685975  0.0172739541160594 
                283                 262                 273                 230 
 0.0174939864421605  0.0174951994879454  0.0177547118273696  0.0178593575592211 
                536                 463                 164                 227 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0198854061341422  0.0199234423280911 
                154                 206                 159                 511 
 0.0201068974293713  0.0206237424547284   0.020628078817734  0.0207115701072462 
                259                 141                 328                 150 
 0.0208385638965604   0.020919175911252  0.0211693548387097  0.0217065004041104 
                180                 151                   9                 450 
 0.0217617659308621  0.0217782577393808  0.0220403022670025  0.0224536670362744 
                247                 273                  83                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774   0.023341049382716  0.0234632323008031 
                127                 199                 439                 136 
 0.0235011990407674  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                209                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0242544731610338 
                 68                 227                 163                  61 
 0.0243264977885002  0.0243547800799709  0.0246305418719212  0.0247417579018989 
                307                 139                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0253881661770877   0.025439388079584  0.0256829707181417 
                153                 203                 323                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0272490757223059  0.0279437271150511   0.027964785085448 
                243                 394                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0290282520956225  0.0292200966996006  0.0292865871644684 
                135                  61                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299939283545841 
                 95                 247                 176                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
 0.0308211473565804  0.0312345066931086   0.031352533722202   0.031377415351888 
                114                 168                 157                 254 
 0.0315893385982231  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                 97                  56                  66                  58 
 0.0325693606755127  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                166                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0343403607911324  0.0344104070499371 
                122                  90                 235                 183 
 0.0345168698109875  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                180                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0351497282512167  0.0351973182995581 
                291                  53                 406                 349 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0366379310344828  0.0367789392179636 
                223                 183                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0373638098364692  0.0373705538045925 
                 26                 313                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0391606080634501 
                231                 348                 178                 237 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412642669007902 
                185                   9                 120                 198 
 0.0412961567445365    0.04203013481364  0.0422836752899197  0.0423121387283237 
                298                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0433547898523287  0.0433574207893274 
                197                 221                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                225                 181                 137                  90 
  0.044525215810995  0.0445749030296677  0.0452668098463572  0.0454771657160357 
                226                 328                  54                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0463034418891804 
                 53                 427                 125                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012  0.0470430107526882  0.0473145307359627   0.047542735042735 
                226                  76                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513616687062777  0.0516417910447761 
                224                 194                 343                 154 
  0.052053981907163  0.0522119900389417  0.0522693757168606  0.0526235972095845 
                167                 394                 165                 204 
 0.0527306967984934   0.053186119873817   0.053840499816244  0.0541623127830024 
                 78                 493                 239                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0572625698324022 
                149                 181                 239                 208 
 0.0577124691399777  0.0579365729738589   0.058057312988463  0.0601947477131897 
                443                 327                 454                 127 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0649717514124294  0.0654566518632941  0.0659246575342466 
                157                 333                 179                 214 
  0.065989847715736  0.0662208091218068   0.066402490801019  0.0664614270191959 
                104                 154                 108                 140 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0691271525139389  0.0691703391454302   0.069882777276826 
                282                 160                 148                 107 
 0.0701461377870564  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                287                 135                  76                 125 
 0.0731810490693739  0.0734780628510703  0.0739031028851388   0.074849349825563 
                147                 227                 356                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0761834556584725 
                176                  72                 180                 238 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0808438558669541 
                292                 146                 126                 174 
  0.081692573402418  0.0819262038774234  0.0845114315664221  0.0850873264666368 
                331                  81                 171                 181 
 0.0850877192982456  0.0871937608509935  0.0879211175020542  0.0907393359397794 
                166                 330                 110                  78 
 0.0913471466923659  0.0919729186043997  0.0926889714993804  0.0931930062807673 
                224                 315                 144                  55 
 0.0941611024293223  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                197                 140                 163                 209 
 0.0961078221438468  0.0964175143741707  0.0990077653149267   0.100058147336405 
                 80                 149                 185                 399 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.105905511811024   0.108005366726297   0.108166470357283 
                167                 345                 171                 170 
  0.110151036178433   0.114229765013055   0.114525835974502   0.117099936431463 
                190                  73                 198                 174 
  0.119464797706276   0.121081745543946   0.125267338832875   0.126307739369838 
                199                 102                 175                 204 
  0.136729555838747   0.145816826598586   0.154871196536584   0.181258488003622 
                383                 388                 210                 190 
  0.185637891520244 
                262 

> ##########################
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0103092783505155  0.0111783249552697  0.0116639598405433  0.0118375774260151 
                  2                 444                 365                 120 
 0.0128509045539613  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                411                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0146315889810314    0.01517663563321 
                469                 146                 487                 226 
  0.015375854214123  0.0154054184575264  0.0163213683449771  0.0163260512097721 
                 40                 132                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0166853053008276  0.0166950069562529    0.01692628480314  0.0172651069685975 
                151                 283                 262                 273 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0177547118273696 
                230                 536                 463                 164 
 0.0178593575592211  0.0180937818552497  0.0182452374563992  0.0186451971127152 
                227                 156                 211                 587 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0198854061341422 
                242                 154                 206                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0220403022670025 
                450                 247                 273                  83 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774   0.023341049382716 
                281                 127                 199                 439 
 0.0234632323008031  0.0235011990407674  0.0236710130391174  0.0237315875613748 
                136                 209                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253881661770877 
                268                 166                 153                 203 
  0.025439388079584  0.0256829707181417  0.0257910706545297   0.026079869600652 
                323                 187                 259                 213 
 0.0261760937213985  0.0264531848242255  0.0266724967205947  0.0267139027192646 
                306                 166                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0272490757223059 
                175                 200                 243                 394 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617   0.028899183763512  0.0290282520956225 
                289                 290                 135                  61 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295730980205104 
                174                 331                  95                 247 
 0.0298372513562387  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                176                 228                 366                 375 
  0.030188679245283  0.0301942222947609  0.0308211473565804  0.0312345066931086 
                245                 169                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320470415288497  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 66                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353873479983604    0.03547209181012 
                406                 349                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0366379310344828  0.0367789392179636  0.0369127516778524  0.0369817341324224 
                119                 148                  26                 313 
 0.0370029389894126  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                167                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382320029839612  0.0383953168044077 
                114                  89                 123                 231 
 0.0384615384615385  0.0386931402066889  0.0391606080634501  0.0403430749682338 
                348                 178                 237                 185 
 0.0408432147562582  0.0412392825206459  0.0412642669007902  0.0412961567445365 
                  9                 120                 198                 298 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0426995042379658 
                384                 292                 187                 197 
 0.0431638211196045  0.0433547898523287  0.0433574207893274  0.0434699883302045 
                221                 312                 209                 515 
 0.0435029049171036  0.0435547734271887  0.0436484634957917  0.0437311002558735 
                177                 176                 227                 225 
 0.0439361466262656  0.0441482715535194  0.0442073170731707   0.044525215810995 
                181                 137                  90                 226 
 0.0445749030296677  0.0452668098463572  0.0454771657160357  0.0458015267175573 
                328                  54                 193                  53 
 0.0458288578589331  0.0461725394896719  0.0463034418891804  0.0463450600379187 
                427                 125                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
 0.0470430107526882  0.0473145307359627   0.047542735042735  0.0475452196382429 
                 76                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0492055356227576 
                 35                 132                 165                  98 
 0.0494997367035282  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                106                  37                 509                 224 
 0.0512921525370312  0.0513616687062777  0.0516417910447761   0.052053981907163 
                194                 343                 154                 167 
 0.0522119900389417  0.0522693757168606  0.0526235972095845  0.0527306967984934 
                394                 165                 204                  78 
  0.053186119873817   0.053840499816244  0.0541623127830024  0.0542635658914729 
                493                 239                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0572625698324022  0.0577124691399777 
                181                 239                 208                 443 
 0.0579365729738589   0.058057312988463  0.0601947477131897  0.0605700712589074 
                327                 454                 127                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0691271525139389  0.0691703391454302   0.069882777276826 
                282                 160                 148                 107 
 0.0701461377870564  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                287                 135                  76                 125 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761834556584725              0.0765  0.0771307365985345   0.077457264957265 
                238                 206                 144                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0799757649197213 
                214                 292                 146                 126 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0845114315664221 
                174                 331                  81                 171 
 0.0850873264666368  0.0850877192982456  0.0871937608509935  0.0879211175020542 
                181                 166                 330                 110 
 0.0903323105725727  0.0907393359397794  0.0913471466923659  0.0919729186043997 
                195                  78                 224                 315 
 0.0926889714993804  0.0931930062807673  0.0936348693532846  0.0941611024293223 
                144                  55                  98                 197 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0961078221438468 
                140                 163                 209                  80 
 0.0964175143741707  0.0990077653149267   0.100058147336405   0.101467214104577 
                149                 185                 399                 269 
  0.102649006622517    0.10270393092479   0.102815564694717   0.103008945513689 
                184                 157                 134                 167 
  0.105905511811024   0.108005366726297   0.108166470357283   0.110151036178433 
                345                 171                 170                 190 
  0.114229765013055   0.114525835974502   0.117099936431463   0.119464797706276 
                 73                 198                 174                 199 
  0.121081745543946   0.123858909955167   0.125267338832875   0.126307739369838 
                102                 269                 175                 204 
  0.136729555838747   0.145816826598586   0.154871196536584   0.172022950473442 
                383                 388                 210                 232 
  0.181258488003622   0.185637891520244    0.20463712781353 
                190                 262                 276 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0103092783505155  0.0111783249552697  0.0116639598405433  0.0118375774260151 
                  2                 444                 365                 120 
 0.0128509045539613  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                411                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0146315889810314    0.01517663563321 
                469                 146                 487                 226 
  0.015375854214123  0.0154054184575264  0.0163213683449771  0.0163260512097721 
                 40                 132                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0166853053008276  0.0166950069562529    0.01692628480314  0.0172651069685975 
                151                 283                 262                 273 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0177547118273696 
                230                 536                 463                 164 
 0.0178593575592211  0.0180937818552497  0.0182452374563992  0.0186451971127152 
                227                 156                 211                 587 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0198854061341422 
                242                 154                 206                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0220403022670025 
                450                 247                 273                  83 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774   0.023341049382716 
                281                 127                 199                 439 
 0.0233871878883742  0.0234632323008031  0.0235011990407674  0.0236710130391174 
                 76                 136                 209                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0246305418719212  0.0247417579018989   0.024763619990995 
                139                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0253881661770877   0.025439388079584  0.0256829707181417  0.0257910706545297 
                203                 323                 187                 259 
  0.026079869600652  0.0261760937213985  0.0264531848242255  0.0266724967205947 
                213                 306                 166                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0272490757223059  0.0279437271150511   0.027964785085448  0.0282313475062647 
                394                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617   0.028899183763512 
                 65                 289                 290                 135 
 0.0290282520956225  0.0292200966996006  0.0292865871644684   0.029377657518361 
                 61                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0299939283545841  0.0300218340611354 
                247                 176                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609  0.0308211473565804 
                375                 245                 169                 114 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0315893385982231 
                168                 157                 254                  97 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0325693606755127 
                 56                  66                  58                 166 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                 90                 235                 183                 180 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0351497282512167  0.0351973182995581  0.0353873479983604 
                 53                 406                 349                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0366379310344828  0.0367789392179636  0.0369127516778524 
                183                 119                 148                  26 
 0.0369817341324224  0.0370029389894126  0.0373638098364692  0.0373705538045925 
                313                 167                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0391606080634501 
                231                 348                 178                 237 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412642669007902 
                185                   9                 120                 198 
 0.0412961567445365    0.04203013481364  0.0422836752899197  0.0423121387283237 
                298                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0433547898523287  0.0433574207893274 
                197                 221                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                225                 181                 137                  90 
  0.044525215810995  0.0445749030296677  0.0452668098463572  0.0454771657160357 
                226                 328                  54                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0463034418891804 
                 53                 427                 125                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012  0.0470430107526882  0.0473145307359627   0.047542735042735 
                226                  76                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513616687062777  0.0516417910447761 
                224                 194                 343                 154 
  0.052053981907163  0.0522119900389417  0.0522693757168606  0.0526235972095845 
                167                 394                 165                 204 
 0.0527306967984934   0.053186119873817   0.053840499816244  0.0541211987798358 
                 78                 493                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0601947477131897  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                127                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0649717514124294  0.0654566518632941 
                 88                 157                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0676933491284481   0.067850348763475 
                108                 140                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0691271525139389 
                189                 163                 282                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0704392560348239 
                148                 107                 287                 135 
 0.0705556460811471  0.0710715061943056  0.0731810490693739  0.0734780628510703 
                 76                 125                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061   0.077792732166891 
                144                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0808438558669541   0.081692573402418 
                146                 126                 174                 331 
 0.0819262038774234  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                 81                  67                 171                 181 
 0.0850877192982456  0.0871937608509935  0.0879211175020542  0.0903323105725727 
                166                 330                 110                 195 
 0.0907393359397794  0.0907575035731301  0.0913471466923659  0.0919729186043997 
                 78                 236                 224                 315 
 0.0926889714993804  0.0931930062807673  0.0936348693532846  0.0941611024293223 
                144                  55                  98                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0961078221438468  0.0964175143741707  0.0990077653149267   0.100058147336405 
                 80                 149                 185                 399 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.105905511811024   0.108005366726297   0.108166470357283 
                167                 345                 171                 170 
  0.110151036178433   0.114229765013055   0.114525835974502   0.117099936431463 
                190                  73                 198                 174 
  0.119464797706276   0.121081745543946              0.1225   0.123858909955167 
                199                 102                  73                 269 
  0.125267338832875   0.126307739369838   0.131510445635971   0.136729555838747 
                175                 204                 296                 383 
  0.145816826598586   0.154871196536584   0.172022950473442   0.181258488003622 
                388                 210                 232                 190 
  0.185637891520244   0.189697630293488    0.20463712781353    0.25564486542374 
                262                 218                 276                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0103092783505155  0.0111783249552697  0.0116639598405433  0.0118375774260151 
                  2                 444                 365                 120 
 0.0128509045539613  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                411                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0146315889810314    0.01517663563321 
                469                 146                 487                 226 
  0.015375854214123  0.0154054184575264  0.0163213683449771  0.0163260512097721 
                 40                 132                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0166853053008276  0.0166950069562529    0.01692628480314  0.0172651069685975 
                151                 283                 262                 273 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0177547118273696 
                230                 536                 463                 164 
 0.0178593575592211  0.0180937818552497  0.0182452374563992  0.0186451971127152 
                227                 156                 211                 587 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0198854061341422 
                242                 154                 206                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0220403022670025 
                450                 247                 273                  83 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774   0.023341049382716 
                281                 127                 199                 439 
 0.0233871878883742  0.0234632323008031  0.0235011990407674  0.0236710130391174 
                 76                 136                 209                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0246305418719212  0.0247417579018989   0.024763619990995 
                139                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0253881661770877   0.025439388079584  0.0256829707181417  0.0257910706545297 
                203                 323                 187                 259 
  0.026079869600652  0.0261760937213985  0.0264531848242255  0.0266724967205947 
                213                 306                 166                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0272490757223059            0.027375  0.0279437271150511   0.027964785085448 
                394                  86                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0290282520956225  0.0292200966996006  0.0292865871644684 
                135                  61                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299939283545841 
                 95                 247                 176                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
 0.0308211473565804  0.0312345066931086   0.031352533722202   0.031377415351888 
                114                 168                 157                 254 
 0.0315893385982231  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                 97                  56                  66                  58 
 0.0325693606755127  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                166                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0343403607911324  0.0344104070499371 
                122                  90                 235                 183 
 0.0345168698109875  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                180                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0351497282512167  0.0351973182995581 
                291                  53                 406                 349 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0366379310344828  0.0367789392179636 
                223                 183                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0370029389894126  0.0373638098364692 
                 26                 313                 167                 334 
 0.0373705538045925  0.0375362566114997  0.0378919022889017  0.0381717729784028 
                 13                 260                 114                  89 
 0.0382320029839612  0.0383953168044077  0.0384615384615385  0.0386931402066889 
                123                 231                 348                 178 
 0.0391606080634501  0.0403430749682338  0.0408432147562582  0.0412392825206459 
                237                 185                   9                 120 
 0.0412642669007902  0.0412852723944195  0.0412961567445365    0.04203013481364 
                198                 235                 298                 384 
 0.0422836752899197  0.0423121387283237  0.0426995042379658  0.0431638211196045 
                292                 187                 197                 221 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0435547734271887  0.0436484634957917  0.0437311002558735  0.0439361466262656 
                176                 227                 225                 181 
 0.0441482715535194  0.0442073170731707   0.044525215810995  0.0445749030296677 
                137                  90                 226                 328 
 0.0452668098463572  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                 54                 193                  53                 427 
 0.0461725394896719  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                125                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0492055356227576  0.0494997367035282 
                132                 165                  98                 106 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0512921525370312 
                 37                 509                 224                 194 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0526235972095845  0.0527306967984934   0.053186119873817 
                165                 204                  78                 493 
  0.053840499816244  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                239                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0572625698324022  0.0577124691399777 
                181                 239                 208                 443 
 0.0579365729738589   0.058057312988463  0.0601947477131897  0.0605700712589074 
                327                 454                 127                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0691271525139389  0.0691703391454302   0.069882777276826 
                282                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0722415428390768  0.0729649936735555  0.0731810490693739 
                125                 123                  72                 147 
 0.0734780628510703  0.0735163861824624  0.0739031028851388   0.074849349825563 
                227                 170                 356                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0761834556584725 
                176                  72                 180                 238 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0808438558669541 
                292                 146                 126                 174 
  0.081692573402418  0.0819262038774234  0.0829190693974945  0.0845114315664221 
                331                  81                  67                 171 
 0.0850873264666368  0.0850877192982456  0.0871937608509935  0.0879211175020542 
                181                 166                 330                 110 
 0.0903323105725727  0.0907393359397794  0.0907575035731301  0.0913471466923659 
                195                  78                 236                 224 
 0.0919729186043997  0.0920472328923033  0.0926889714993804  0.0931930062807673 
                315                 156                 144                  55 
 0.0936348693532846  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                 98                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0961078221438468  0.0964175143741707 
                163                 209                  80                 149 
 0.0990077653149267   0.100058147336405   0.101467214104577   0.102649006622517 
                185                 399                 269                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.105905511811024 
                157                 134                 167                 345 
  0.108005366726297   0.108166470357283   0.110151036178433   0.114229765013055 
                171                 170                 190                  73 
  0.114525835974502   0.117099936431463   0.119464797706276   0.120465801097577 
                198                 174                 199                 328 
  0.121081745543946              0.1225   0.123858909955167   0.125267338832875 
                102                  73                 269                 175 
  0.126307739369838   0.131510445635971   0.136729555838747   0.145816826598586 
                204                 296                 383                 388 
  0.146203845806626   0.154871196536584   0.172022950473442   0.181258488003622 
                188                 210                 232                 190 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> ##########################
> #Finland
> ##########################
> 
> 
> country="Finland"

> cntry<-"FI"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0103092783505155  0.0111783249552697  0.0116639598405433  0.0118375774260151 
                  2                 444                 365                 120 
 0.0128509045539613  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                411                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0146315889810314    0.01517663563321 
                469                 146                 487                 226 
  0.015375854214123  0.0154054184575264  0.0163213683449771  0.0163260512097721 
                 40                 132                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0166853053008276  0.0166950069562529    0.01692628480314  0.0172651069685975 
                151                 283                 262                 273 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0177547118273696 
                230                 536                 463                 164 
 0.0178593575592211  0.0180937818552497  0.0182452374563992  0.0186451971127152 
                227                 156                 211                 587 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0198854061341422 
                242                 154                 206                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217929668152551 
                450                 247                 273                 174 
 0.0220403022670025  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                 83                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
  0.023341049382716  0.0233871878883742  0.0234632323008031  0.0235011990407674 
                439                  76                 136                 209 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0246305418719212  0.0247417579018989 
                307                 139                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0253881661770877   0.025439388079584  0.0256829707181417 
                153                 203                 323                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0272490757223059            0.027375  0.0279437271150511 
                243                 394                  86                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617   0.028899183763512  0.0290282520956225  0.0292200966996006 
                290                 135                  61                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609  0.0308211473565804  0.0312345066931086   0.031352533722202 
                169                 114                 168                 157 
  0.031377415351888  0.0315893385982231  0.0320326150262085  0.0320470415288497 
                254                  97                  56                  66 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0332120109190173 
                 58                 166                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0343403607911324 
                142                 122                  90                 235 
 0.0344104070499371  0.0345168698109875  0.0347459003084916  0.0348244147157191 
                183                 180                 203                 152 
 0.0348890414092885  0.0349115972430327  0.0350253807106599  0.0351497282512167 
                205                 291                  53                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0366379310344828  0.0367789392179636  0.0369127516778524  0.0369817341324224 
                119                 148                  26                 313 
 0.0370029389894126  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                167                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382320029839612  0.0383953168044077 
                114                  89                 123                 231 
 0.0384615384615385  0.0386931402066889  0.0391606080634501  0.0403430749682338 
                348                 178                 237                 185 
 0.0408432147562582  0.0412392825206459  0.0412642669007902  0.0412852723944195 
                  9                 120                 198                 235 
 0.0412961567445365    0.04203013481364  0.0422836752899197  0.0423121387283237 
                298                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0433547898523287  0.0433574207893274 
                197                 221                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                225                 181                 137                  90 
  0.044525215810995  0.0445749030296677  0.0452668098463572  0.0454771657160357 
                226                 328                  54                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0463034418891804 
                 53                 427                 125                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012  0.0470430107526882  0.0473145307359627   0.047542735042735 
                226                  76                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513616687062777  0.0516417910447761 
                224                 194                 343                 154 
  0.052053981907163  0.0522119900389417  0.0522693757168606  0.0526235972095845 
                167                 394                 165                 204 
 0.0527306967984934   0.053186119873817   0.053840499816244  0.0541211987798358 
                 78                 493                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0594954783436459  0.0601947477131897  0.0605700712589074  0.0605714285714286 
                271                 127                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0649717514124294 
                341                  88                 157                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0676933491284481 
                 50                 108                 140                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061   0.077792732166891 
                144                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                146                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0829190693974945  0.0845114315664221 
                331                  81                  67                 171 
 0.0850873264666368  0.0850877192982456  0.0871771217712177  0.0871937608509935 
                181                 166                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0903323105725727  0.0907393359397794 
                110                 168                 195                  78 
 0.0907575035731301  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                236                 224                 315                 156 
 0.0926889714993804  0.0931930062807673  0.0936348693532846  0.0941611024293223 
                144                  55                  98                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0961078221438468  0.0964175143741707  0.0990077653149267   0.100058147336405 
                 80                 149                 185                 399 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.105905511811024   0.108005366726297   0.108166470357283 
                167                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.117099936431463   0.119464797706276   0.120465801097577   0.121081745543946 
                174                 199                 328                 102 
             0.1225   0.123858909955167   0.125036689169357   0.125267338832875 
                 73                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.136729555838747   0.145816826598586 
                204                 296                 383                 388 
  0.146203845806626   0.154871196536584   0.172022950473442   0.181258488003622 
                188                 210                 232                 190 
  0.182134570765661   0.185637891520244   0.189697630293488    0.20463712781353 
                212                 262                 218                 276 
  0.234804706537631    0.25564486542374 
                229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> #Change parameter values
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
 0.0103092783505155  0.0111783249552697  0.0116639598405433  0.0118375774260151 
                  2                 444                 365                 120 
 0.0128509045539613  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                411                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0146315889810314    0.01517663563321 
                469                 146                 487                 226 
  0.015375854214123  0.0154054184575264  0.0163213683449771  0.0163260512097721 
                 40                 132                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0166853053008276  0.0166950069562529    0.01692628480314  0.0172651069685975 
                151                 283                 262                 273 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0177547118273696 
                230                 536                 463                 164 
 0.0178593575592211  0.0180937818552497  0.0182452374563992  0.0186451971127152 
                227                 156                 211                 587 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0198854061341422 
                242                 154                 206                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217929668152551 
                450                 247                 273                 174 
 0.0220403022670025  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                 83                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
  0.023341049382716  0.0233871878883742  0.0234632323008031  0.0235011990407674 
                439                  76                 136                 209 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0246305418719212  0.0247417579018989 
                307                 139                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0253881661770877   0.025439388079584  0.0256829707181417 
                153                 203                 323                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0272490757223059            0.027375 
                200                 243                 394                  86 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617   0.028899183763512  0.0290282520956225 
                289                 290                 135                  61 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295730980205104 
                174                 331                  95                 247 
 0.0298372513562387  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                176                 228                 366                 375 
  0.030188679245283  0.0301942222947609  0.0308211473565804  0.0312345066931086 
                245                 169                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320470415288497  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 66                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0366379310344828  0.0367789392179636  0.0369127516778524 
                183                 119                 148                  26 
 0.0369817341324224  0.0370029389894126  0.0373638098364692  0.0373705538045925 
                313                 167                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0391606080634501 
                231                 348                 178                 237 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412587412587413 
                185                   9                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365    0.04203013481364 
                198                 235                 298                 384 
 0.0422836752899197  0.0423121387283237  0.0426995042379658  0.0431638211196045 
                292                 187                 197                 221 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0435547734271887  0.0436484634957917  0.0437311002558735  0.0439361466262656 
                176                 227                 225                 181 
 0.0441482715535194  0.0442073170731707   0.044525215810995  0.0445749030296677 
                137                  90                 226                 328 
 0.0452668098463572  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                 54                 193                  53                 427 
 0.0461725394896719  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                125                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0492055356227576  0.0494997367035282 
                132                 165                  98                 106 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0512921525370312 
                 37                 509                 224                 194 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0526235972095845  0.0527306967984934   0.053186119873817 
                165                 204                  78                 493 
  0.053840499816244  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                239                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0572625698324022  0.0577124691399777 
                181                 239                 208                 443 
 0.0579365729738589   0.058057312988463  0.0594954783436459  0.0601947477131897 
                327                 454                 271                 127 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0649717514124294  0.0654566518632941 
                157                 248                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0676933491284481   0.067850348763475 
                108                 140                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0691271525139389 
                189                 163                 282                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0722415428390768 
                135                  76                 125                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761834556584725              0.0765  0.0771307365985345 
                180                 238                 206                 144 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                 81                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0897435897435897  0.0903323105725727 
                110                 168                 154                 195 
 0.0907393359397794  0.0907575035731301  0.0913471466923659  0.0919729186043997 
                 78                 236                 224                 315 
 0.0920472328923033  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                156                 144                  55                  98 
 0.0941611024293223  0.0942935459755794  0.0944649446494465  0.0946155169447789 
                197                  92                 140                 163 
 0.0951444859445646  0.0961078221438468  0.0964175143741707  0.0984356197352587 
                209                  80                 149                 295 
 0.0990077653149267   0.100058147336405   0.101239669421488   0.101467214104577 
                185                 399                 143                 269 
  0.102649006622517    0.10270393092479   0.102815564694717   0.103008945513689 
                184                 157                 134                 167 
  0.105905511811024   0.108005366726297   0.108166470357283   0.109404990403071 
                345                 171                 170                 265 
  0.110151036178433   0.114229765013055   0.114525835974502   0.116141117702154 
                190                  73                 198                 230 
  0.117099936431463   0.119464797706276   0.120465801097577   0.121081745543946 
                174                 199                 328                 102 
             0.1225   0.123858909955167   0.125036689169357   0.125267338832875 
                 73                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.136729555838747   0.145816826598586 
                204                 296                 383                 388 
  0.146203845806626   0.154871196536584   0.172022950473442   0.181258488003622 
                188                 210                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
   0.20463712781353   0.234804706537631    0.25564486542374 
                276                 229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
0.00992145514675486  0.0103092783505155  0.0111783249552697  0.0116639598405433 
                167                   2                 444                 365 
 0.0118375774260151  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                120                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0146315889810314 
                227                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180937818552497  0.0182452374563992 
                164                 227                 156                 211 
 0.0186451971127152  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                587                 242                 154                 206 
 0.0196571428571429  0.0198854061341422  0.0199234423280911  0.0201068974293713 
                283                 159                 511                 259 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0208385638965604 
                141                 328                 150                 180 
  0.020919175911252  0.0211693548387097  0.0217065004041104  0.0217617659308621 
                151                   9                 450                 247 
 0.0217782577393808  0.0217929668152551  0.0220403022670025  0.0224536670362744 
                273                 174                  83                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774   0.023341049382716  0.0233871878883742 
                127                 199                 439                  76 
 0.0234632323008031  0.0235011990407674  0.0236710130391174  0.0237315875613748 
                136                 209                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253881661770877 
                268                 166                 153                 203 
  0.025439388079584  0.0255052935514918  0.0256829707181417  0.0257910706545297 
                323                 264                 187                 259 
  0.026079869600652  0.0261760937213985  0.0264531848242255  0.0266429840142096 
                213                 306                 166                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0272490757223059            0.027375  0.0279437271150511 
                243                 394                  86                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617   0.028899183763512  0.0290282520956225  0.0292200966996006 
                290                 135                  61                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609  0.0308211473565804  0.0312345066931086   0.031352533722202 
                169                 114                 168                 157 
  0.031377415351888  0.0315893385982231  0.0320326150262085  0.0320470415288497 
                254                  97                  56                  66 
 0.0320665083135392  0.0325693606755127  0.0331766657450926  0.0332120109190173 
                 58                 166                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0343403607911324 
                142                 122                  90                 235 
 0.0344104070499371  0.0345168698109875  0.0347459003084916  0.0348244147157191 
                183                 180                 203                 152 
 0.0348890414092885  0.0349115972430327  0.0350253807106599  0.0351497282512167 
                205                 291                  53                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0366379310344828  0.0367789392179636  0.0369127516778524  0.0369817341324224 
                119                 148                  26                 313 
 0.0370029389894126  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                167                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382320029839612  0.0383953168044077 
                114                  89                 123                 231 
 0.0384615384615385  0.0386931402066889  0.0391606080634501  0.0395238095238095 
                348                 178                 237                 147 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412587412587413 
                185                   9                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365    0.04203013481364 
                198                 235                 298                 384 
 0.0422836752899197  0.0423121387283237  0.0426995042379658  0.0431638211196045 
                292                 187                 197                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434699883302045 
                135                 312                 209                 515 
 0.0435029049171036  0.0435547734271887  0.0436484634957917  0.0437311002558735 
                177                 176                 227                 225 
 0.0439361466262656  0.0441482715535194  0.0442073170731707   0.044525215810995 
                181                 137                  90                 226 
 0.0445749030296677  0.0452668098463572  0.0454771657160357  0.0458015267175573 
                328                  54                 193                  53 
 0.0458288578589331  0.0461725394896719  0.0463034418891804  0.0463450600379187 
                427                 125                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
 0.0470430107526882  0.0473145307359627   0.047542735042735  0.0475452196382429 
                 76                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513616687062777  0.0516417910447761 
                224                 194                 343                 154 
  0.052053981907163  0.0522119900389417  0.0522693757168606  0.0526235972095845 
                167                 394                 165                 204 
 0.0527306967984934   0.053186119873817  0.0538116591928251   0.053840499816244 
                 78                 493                 131                 239 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0555828824397442  0.0572625698324022  0.0577124691399777 
                239                 283                 208                 443 
 0.0579365729738589   0.058057312988463  0.0594954783436459  0.0601947477131897 
                327                 454                 271                 127 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0649717514124294  0.0654566518632941 
                157                 248                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0676933491284481   0.067850348763475 
                108                 140                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0691271525139389 
                189                 163                 282                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0722415428390768 
                135                  76                 125                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761834556584725              0.0765  0.0771307365985345 
                180                 238                 206                 144 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                 81                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0897435897435897  0.0903323105725727 
                110                 168                 154                 195 
 0.0907393359397794  0.0907575035731301  0.0913471466923659  0.0919729186043997 
                 78                 236                 224                 315 
 0.0920472328923033  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                156                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0961078221438468  0.0964175143741707 
                163                 209                  80                 149 
 0.0984356197352587  0.0990077653149267   0.100058147336405   0.101239669421488 
                295                 185                 399                 143 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.105905511811024   0.108005366726297   0.108166470357283 
                167                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.123858909955167   0.125036689169357 
                102                  73                 269                 261 
  0.125267338832875   0.126307739369838   0.131510445635971   0.136729555838747 
                175                 204                 296                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.172022950473442 
                388                 188                 210                 232 
  0.181258488003622   0.182134570765661   0.184947958366693   0.185637891520244 
                190                 212                 211                 262 
  0.189697630293488    0.20463712781353   0.234804706537631    0.25564486542374 
                218                 276                 229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
0.00992145514675486  0.0103092783505155  0.0111783249552697  0.0116639598405433 
                167                   2                 444                 365 
 0.0118375774260151  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                120                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0146315889810314 
                227                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180937818552497 
                164                 227                 370                 156 
 0.0182452374563992  0.0186451971127152  0.0188848920863309  0.0194376952447067 
                211                 587                 242                 154 
 0.0194924196145943  0.0196571428571429  0.0198854061341422  0.0199234423280911 
                206                 283                 159                 511 
 0.0201068974293713  0.0206237424547284   0.020628078817734  0.0207115701072462 
                259                 141                 328                 150 
 0.0208385638965604   0.020919175911252  0.0211693548387097  0.0217065004041104 
                180                 151                   9                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0220403022670025  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                 83                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
  0.023341049382716  0.0233871878883742  0.0234632323008031  0.0235011990407674 
                439                  76                 136                 209 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0246305418719212  0.0247417579018989 
                307                 139                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0253881661770877   0.025439388079584  0.0255052935514918 
                153                 203                 323                 264 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                166                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0272490757223059 
                175                 200                 243                 394 
           0.027375  0.0279437271150511   0.027964785085448  0.0282313475062647 
                 86                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617   0.028899183763512 
                 65                 289                 290                 135 
 0.0290282520956225  0.0292200966996006  0.0292865871644684   0.029377657518361 
                 61                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0299939283545841  0.0300218340611354 
                247                 176                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609  0.0308211473565804 
                375                 245                 169                 114 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0315893385982231 
                168                 157                 254                  97 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0325693606755127 
                 56                  66                  58                 166 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                 90                 235                 183                 180 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                 53                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0365853658536585  0.0366379310344828 
                223                 183                 179                 119 
 0.0367789392179636  0.0369127516778524  0.0369817341324224  0.0370029389894126 
                148                  26                 313                 167 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382320029839612  0.0383953168044077 
                114                  89                 123                 231 
 0.0384615384615385  0.0386931402066889  0.0391606080634501  0.0395238095238095 
                348                 178                 237                 147 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412587412587413 
                185                   9                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0415865384615385 
                198                 235                 298                 319 
 0.0416666666666667    0.04203013481364  0.0422836752899197  0.0423121387283237 
                153                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                209                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707   0.044525215810995  0.0445749030296677 
                137                  90                 226                 328 
 0.0452668098463572  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                 54                 193                  53                 427 
 0.0461725394896719  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                125                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494997367035282  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                106                  37                 509                 224 
 0.0512921525370312  0.0513616687062777  0.0516417910447761   0.052053981907163 
                194                 343                 154                 167 
 0.0522119900389417  0.0522693757168606  0.0526235972095845  0.0527306967984934 
                394                 165                 204                  78 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0555828824397442  0.0572625698324022  0.0577124691399777  0.0579365729738589 
                283                 208                 443                 327 
  0.058057312988463  0.0594954783436459  0.0601947477131897  0.0605700712589074 
                454                 271                 127                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0649717514124294  0.0654566518632941  0.0659246575342466 
                248                 333                 179                 214 
  0.065989847715736  0.0662208091218068  0.0663316582914573   0.066402490801019 
                104                 154                  50                 108 
 0.0664614270191959  0.0676933491284481   0.067850348763475   0.068041136618414 
                140                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0691271525139389  0.0691703391454302 
                163                 282                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0722415428390768  0.0729649936735555 
                 76                 125                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761834556584725              0.0765  0.0771307365985345   0.077457264957265 
                238                 206                 144                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0799757649197213 
                214                 292                 146                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0897435897435897  0.0903323105725727 
                110                 168                 154                 195 
 0.0907393359397794  0.0907575035731301  0.0913471466923659  0.0919729186043997 
                 78                 236                 224                 315 
 0.0920472328923033  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                156                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0961078221438468  0.0964175143741707 
                163                 209                  80                 149 
 0.0984356197352587  0.0990077653149267   0.100058147336405   0.101239669421488 
                295                 185                 399                 143 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.105905511811024   0.108005366726297   0.108166470357283 
                167                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.123858909955167   0.125036689169357 
                102                  73                 269                 261 
  0.125267338832875   0.126307739369838   0.131510445635971   0.136729555838747 
                175                 204                 296                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.172022950473442 
                388                 188                 210                 232 
  0.181258488003622   0.182134570765661   0.184947958366693   0.185637891520244 
                190                 212                 211                 262 
  0.189697630293488    0.20463712781353   0.234804706537631    0.25564486542374 
                218                 276                 229                 237 

> ##########################
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
0.00992145514675486  0.0103092783505155  0.0111783249552697  0.0116639598405433 
                167                   2                 444                 365 
 0.0118375774260151  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                120                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0146315889810314 
                227                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0198854061341422 
                154                 206                 283                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0220403022670025  0.0224536670362744  0.0225645183083367 
                174                  83                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                  3                  90                 281                 127 
 0.0231803430690774   0.023341049382716  0.0233871878883742  0.0234632323008031 
                199                 439                  76                 136 
 0.0235011990407674  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                209                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0246305418719212 
                 61                 307                 139                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253712871287129  0.0253881661770877 
                166                 153                 297                 203 
  0.025439388079584  0.0255052935514918  0.0256829707181417  0.0257910706545297 
                323                 264                 187                 259 
  0.026079869600652  0.0261760937213985  0.0264531848242255  0.0266429840142096 
                213                 306                 166                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0272490757223059            0.027375  0.0279437271150511 
                243                 394                  86                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617   0.028899183763512  0.0290282520956225  0.0292200966996006 
                290                 135                  61                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0312345066931086 
                169                 266                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320470415288497  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 66                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0365853658536585  0.0366379310344828  0.0367789392179636 
                183                 179                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0370029389894126  0.0371853546910755 
                 26                 313                 167                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                 89                 123                 231                 348 
 0.0386931402066889  0.0391606080634501  0.0395238095238095  0.0403430749682338 
                178                 237                 147                 185 
 0.0408432147562582  0.0412392825206459  0.0412587412587413  0.0412642669007902 
                  9                 120                 276                 198 
 0.0412852723944195  0.0412961567445365  0.0415865384615385  0.0416666666666667 
                235                 298                 319                 153 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0426995042379658 
                384                 292                 187                 197 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707   0.044525215810995  0.0445749030296677  0.0452668098463572 
                 90                 226                 328                  54 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513616687062777  0.0516417910447761 
                224                 194                 343                 154 
  0.052053981907163  0.0522119900389417  0.0522693757168606  0.0524006824274921 
                167                 394                 165                 285 
 0.0526235972095845  0.0527306967984934   0.053186119873817  0.0538116591928251 
                204                  78                 493                 131 
  0.053840499816244  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                239                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0555828824397442 
                181                 239                 141                 283 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0594954783436459  0.0601947477131897  0.0605700712589074  0.0605714285714286 
                271                 127                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0645476772616137 
                341                  88                 157                 248 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0691271525139389  0.0691703391454302 
                163                 282                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0722415428390768  0.0729649936735555 
                 76                 125                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761834556584725              0.0765  0.0771307365985345   0.077457264957265 
                238                 206                 144                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0799757649197213 
                214                 292                 146                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0897435897435897  0.0903323105725727 
                110                 168                 154                 195 
 0.0907393359397794  0.0907575035731301  0.0913471466923659  0.0919729186043997 
                 78                 236                 224                 315 
 0.0920472328923033  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                156                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0961078221438468  0.0964175143741707 
                163                 209                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
0.00992145514675486  0.0103092783505155  0.0111783249552697  0.0116639598405433 
                167                   2                 444                 365 
 0.0118375774260151  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                120                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0146315889810314 
                227                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0198854061341422 
                154                 206                 283                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0220403022670025  0.0220897615708275  0.0224536670362744 
                174                  83                 377                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774   0.023341049382716  0.0233871878883742 
                127                 199                 439                  76 
 0.0234632323008031  0.0235011990407674  0.0236710130391174  0.0237315875613748 
                136                 209                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0255052935514918  0.0256829707181417 
                203                 323                 264                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0272490757223059            0.027375 
                200                 243                 394                  86 
 0.0275999116802826  0.0279437271150511   0.027964785085448  0.0282313475062647 
                320                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617   0.028899183763512 
                 65                 289                 290                 135 
 0.0290282520956225  0.0292200966996006  0.0292865871644684   0.029377657518361 
                 61                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0299939283545841  0.0300218340611354 
                247                 176                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609   0.030411877394636 
                375                 245                 169                 266 
 0.0308211473565804  0.0312345066931086   0.031352533722202   0.031377415351888 
                114                 168                 157                 254 
 0.0315893385982231  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                 97                  56                  66                  58 
 0.0325693606755127  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                166                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0343403607911324  0.0344104070499371 
                122                  90                 235                 183 
 0.0345168698109875  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                180                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0351497282512167  0.0351973182995581 
                291                  53                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0365853658536585 
                 70                 223                 183                 179 
 0.0366379310344828  0.0367789392179636  0.0369127516778524  0.0369817341324224 
                119                 148                  26                 313 
 0.0370029389894126  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                167                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0391606080634501 
                231                 348                 178                 237 
 0.0395238095238095  0.0401267159450898  0.0403430749682338  0.0408432147562582 
                147                 121                 185                   9 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0415865384615385  0.0416666666666667    0.04203013481364 
                298                 319                 153                 384 
 0.0422836752899197  0.0423121387283237  0.0426995042379658  0.0431638211196045 
                292                 187                 197                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434699883302045 
                135                 312                 209                 515 
 0.0435029049171036  0.0435547734271887  0.0436484634957917  0.0437311002558735 
                177                 176                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
  0.044525215810995  0.0445749030296677  0.0452668098463572  0.0453752181500873 
                226                 328                  54                 186 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0524006824274921  0.0526235972095845  0.0527306967984934 
                165                 285                 204                  78 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0555828824397442  0.0572625698324022  0.0577124691399777 
                141                 283                 208                 443 
 0.0579365729738589   0.058057312988463  0.0594954783436459  0.0601947477131897 
                327                 454                 271                 127 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0649717514124294 
                 88                 157                 248                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0691271525139389  0.0691703391454302   0.069882777276826 
                282                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0722415428390768  0.0729649936735555  0.0731810490693739 
                125                 123                  72                 147 
 0.0734780628510703  0.0735163861824624  0.0739031028851388   0.074849349825563 
                227                 170                 356                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0761834556584725 
                176                  72                 180                 238 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0800351802990325 
                292                 146                 126                 151 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0821542674577818 
                174                 331                  81                 205 
 0.0829190693974945  0.0845114315664221  0.0850873264666368  0.0850877192982456 
                 67                 171                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0885896527285613  0.0897435897435897  0.0903323105725727  0.0907393359397794 
                168                 154                 195                  78 
 0.0907575035731301  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                236                 224                 315                 156 
 0.0926889714993804  0.0931930062807673  0.0936348693532846   0.093978102189781 
                144                  55                  98                 173 
 0.0941611024293223  0.0942935459755794  0.0944649446494465  0.0946155169447789 
                197                  92                 140                 163 
 0.0951444859445646  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                209                 172                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
0.00992145514675486  0.0103092783505155  0.0111783249552697  0.0116639598405433 
                167                   2                 444                 365 
 0.0118375774260151  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                120                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0146315889810314 
                227                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0198854061341422 
                154                 206                 283                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0220403022670025  0.0220897615708275  0.0224536670362744 
                174                  83                 377                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774   0.023341049382716  0.0233871878883742 
                127                 199                 439                  76 
 0.0234632323008031  0.0235011990407674  0.0236710130391174  0.0237315875613748 
                136                 209                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0255052935514918  0.0256829707181417 
                203                 323                 264                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0265044174029005  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                409                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0272490757223059 
                175                 200                 243                 394 
           0.027375  0.0275999116802826  0.0279437271150511   0.027964785085448 
                 86                 320                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0290282520956225  0.0292200966996006  0.0292865871644684 
                135                  61                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299936183790683 
                 95                 247                 176                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0312345066931086 
                169                 266                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320470415288497  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 66                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0365853658536585  0.0366379310344828  0.0367789392179636 
                183                 179                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0370029389894126  0.0371853546910755 
                 26                 313                 167                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                 89                 123                 231                 348 
 0.0386931402066889  0.0391606080634501  0.0395238095238095  0.0401267159450898 
                178                 237                 147                 121 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412587412587413 
                185                   9                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0415865384615385 
                198                 235                 298                 319 
 0.0416666666666667    0.04203013481364  0.0422836752899197  0.0423121387283237 
                153                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                209                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0452668098463572  0.0453752181500873  0.0454081632653061 
                328                  54                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0524006824274921  0.0526235972095845  0.0527306967984934 
                165                 285                 204                  78 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0571776155717762 
                141                 375                 283                 143 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0594954783436459  0.0601947477131897  0.0604450348721355  0.0605700712589074 
                271                 127                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061   0.077792732166891 
                144                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                146                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821542674577818  0.0829190693974945 
                331                  81                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0897435897435897  0.0903323105725727  0.0907393359397794  0.0907575035731301 
                154                 195                  78                 236 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0926889714993804 
                224                 315                 156                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                167                 172                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> #By country
> country="France"

> cntry<-"FR"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
0.00992145514675486  0.0103092783505155  0.0111783249552697  0.0116639598405433 
                167                   2                 444                 365 
 0.0118375774260151  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                120                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0146315889810314 
                227                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0198854061341422 
                154                 206                 283                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0220403022670025  0.0220897615708275  0.0224536670362744 
                174                  83                 377                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774   0.023341049382716  0.0233871878883742 
                127                 199                 439                  76 
 0.0234632323008031  0.0235011990407674  0.0236710130391174  0.0237315875613748 
                136                 209                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0255052935514918  0.0256829707181417 
                203                 323                 264                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0265044174029005  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                409                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0272490757223059 
                175                 200                 243                 394 
           0.027375  0.0275999116802826  0.0279437271150511   0.027964785085448 
                 86                 320                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0290282520956225  0.0292200966996006  0.0292865871644684 
                135                  61                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299936183790683 
                 95                 247                 176                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0312345066931086 
                169                 266                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320470415288497  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 66                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0365853658536585  0.0366379310344828  0.0367789392179636 
                183                 179                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0370029389894126  0.0371853546910755 
                 26                 313                 167                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                 89                 123                 231                 348 
 0.0386931402066889  0.0391606080634501  0.0395238095238095  0.0401267159450898 
                178                 237                 147                 121 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412587412587413 
                185                   9                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0415865384615385 
                198                 235                 298                 319 
 0.0416666666666667    0.04203013481364  0.0422836752899197  0.0423121387283237 
                153                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                209                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0452668098463572  0.0453752181500873  0.0454081632653061 
                328                  54                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0524006824274921  0.0526235972095845  0.0527306967984934 
                165                 285                 204                  78 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0571776155717762 
                141                 375                 283                 143 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0594954783436459  0.0601947477131897  0.0604450348721355  0.0605700712589074 
                271                 127                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061   0.077792732166891 
                144                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                146                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821542674577818  0.0829190693974945 
                331                  81                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0897435897435897  0.0903323105725727  0.0907393359397794  0.0907575035731301 
                154                 195                  78                 236 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0926889714993804 
                224                 315                 156                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                167                 172                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
0.00992145514675486  0.0103092783505155  0.0111783249552697  0.0116639598405433 
                167                   2                 444                 365 
 0.0118375774260151  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                120                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0146315889810314 
                227                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0198854061341422 
                154                 206                 283                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0220403022670025  0.0220897615708275  0.0224536670362744 
                174                  83                 377                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774   0.023341049382716  0.0233871878883742 
                127                 199                 439                  76 
 0.0234632323008031  0.0235011990407674  0.0236710130391174  0.0237315875613748 
                136                 209                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0255052935514918  0.0256829707181417 
                203                 323                 264                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0265044174029005  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                409                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0272490757223059 
                175                 200                 243                 394 
           0.027375  0.0275999116802826  0.0279437271150511   0.027964785085448 
                 86                 320                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0290282520956225  0.0292200966996006  0.0292865871644684 
                135                  61                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299936183790683 
                 95                 247                 176                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0312345066931086 
                169                 266                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320470415288497  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 66                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0365853658536585  0.0366379310344828  0.0367789392179636 
                183                 179                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0370029389894126  0.0371853546910755 
                 26                 313                 167                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                 89                 123                 231                 348 
 0.0386931402066889  0.0391606080634501  0.0395238095238095  0.0401267159450898 
                178                 237                 147                 121 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412587412587413 
                185                   9                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0415865384615385 
                198                 235                 298                 319 
 0.0416666666666667    0.04203013481364  0.0422836752899197  0.0423121387283237 
                153                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                209                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0452668098463572  0.0453752181500873  0.0454081632653061 
                328                  54                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0524006824274921  0.0526235972095845  0.0527306967984934 
                165                 285                 204                  78 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0571776155717762 
                141                 375                 283                 143 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0594954783436459  0.0601947477131897  0.0604450348721355  0.0605700712589074 
                271                 127                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061   0.077792732166891 
                144                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                146                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821542674577818  0.0829190693974945 
                331                  81                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0897435897435897  0.0903323105725727  0.0907393359397794  0.0907575035731301 
                154                 195                  78                 236 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0926889714993804 
                224                 315                 156                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                167                 172                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
0.00992145514675486  0.0103092783505155  0.0111783249552697  0.0116639598405433 
                167                   2                 444                 365 
 0.0118375774260151  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                120                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0146315889810314 
                227                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0198854061341422 
                154                 206                 283                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0220403022670025  0.0220897615708275  0.0224536670362744 
                174                  83                 377                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774   0.023341049382716  0.0233871878883742 
                127                 199                 439                  76 
 0.0234632323008031  0.0235011990407674  0.0236710130391174  0.0237315875613748 
                136                 209                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0255052935514918  0.0256829707181417 
                203                 323                 264                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0265044174029005  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                409                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0272490757223059 
                175                 200                 243                 394 
           0.027375  0.0275999116802826  0.0279437271150511   0.027964785085448 
                 86                 320                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0290282520956225  0.0292200966996006  0.0292865871644684 
                135                  61                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299936183790683 
                 95                 247                 176                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0312345066931086 
                169                 266                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320470415288497  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 66                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0365853658536585  0.0366379310344828  0.0367789392179636 
                183                 179                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0370029389894126  0.0371853546910755 
                 26                 313                 167                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                 89                 123                 231                 348 
 0.0386931402066889  0.0391606080634501  0.0395238095238095  0.0401267159450898 
                178                 237                 147                 121 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412587412587413 
                185                   9                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0415865384615385 
                198                 235                 298                 319 
 0.0416666666666667    0.04203013481364  0.0422836752899197  0.0423121387283237 
                153                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                209                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0452668098463572  0.0453752181500873  0.0454081632653061 
                328                  54                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0524006824274921  0.0526235972095845  0.0527306967984934 
                165                 285                 204                  78 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0571776155717762 
                141                 375                 283                 143 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0594954783436459  0.0601947477131897  0.0604450348721355  0.0605700712589074 
                271                 127                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061   0.077792732166891 
                144                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                146                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821542674577818  0.0829190693974945 
                331                  81                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0897435897435897  0.0903323105725727  0.0907393359397794  0.0907575035731301 
                154                 195                  78                 236 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0926889714993804 
                224                 315                 156                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                167                 172                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
0.00992145514675486  0.0103092783505155  0.0111783249552697  0.0116639598405433 
                167                   2                 444                 365 
 0.0118375774260151  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                120                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0146315889810314 
                227                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0198854061341422 
                154                 206                 283                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0220403022670025  0.0220897615708275  0.0224536670362744 
                174                  83                 377                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774   0.023341049382716  0.0233871878883742 
                127                 199                 439                  76 
 0.0234632323008031  0.0235011990407674  0.0236710130391174  0.0237315875613748 
                136                 209                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0255052935514918  0.0256829707181417 
                203                 323                 264                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0265044174029005  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                409                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0272490757223059 
                175                 200                 243                 394 
           0.027375  0.0275999116802826  0.0279437271150511   0.027964785085448 
                 86                 320                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0290282520956225  0.0292200966996006  0.0292865871644684 
                135                  61                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299936183790683 
                 95                 247                 176                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0312345066931086 
                169                 266                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320470415288497  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 66                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0365853658536585  0.0366379310344828  0.0367789392179636 
                183                 179                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0370029389894126  0.0371853546910755 
                 26                 313                 167                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                 89                 123                 231                 348 
 0.0386931402066889  0.0391606080634501  0.0395238095238095  0.0401267159450898 
                178                 237                 147                 121 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412587412587413 
                185                   9                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0415865384615385 
                198                 235                 298                 319 
 0.0416666666666667    0.04203013481364  0.0422836752899197  0.0423121387283237 
                153                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                209                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0452668098463572  0.0453752181500873  0.0454081632653061 
                328                  54                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0524006824274921  0.0526235972095845  0.0527306967984934 
                165                 285                 204                  78 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0571776155717762 
                141                 375                 283                 143 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0594954783436459  0.0601947477131897  0.0604450348721355  0.0605700712589074 
                271                 127                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061   0.077792732166891 
                144                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                146                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821542674577818  0.0829190693974945 
                331                  81                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0897435897435897  0.0903323105725727  0.0907393359397794  0.0907575035731301 
                154                 195                  78                 236 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0926889714993804 
                224                 315                 156                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                167                 172                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00921675385217608 
                 49                  41                  54                 401 
0.00992145514675486  0.0103092783505155  0.0111783249552697  0.0116639598405433 
                167                   2                 444                 365 
 0.0118375774260151  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                120                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0146315889810314 
                227                 469                 146                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0198854061341422 
                154                 206                 283                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0220403022670025  0.0220897615708275  0.0224536670362744 
                174                  83                 377                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774   0.023341049382716  0.0233871878883742 
                127                 199                 439                  76 
 0.0234632323008031  0.0235011990407674  0.0236710130391174  0.0237315875613748 
                136                 209                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0255052935514918  0.0256829707181417 
                203                 323                 264                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0265044174029005  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                409                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0272490757223059 
                175                 200                 243                 394 
           0.027375  0.0275999116802826  0.0279437271150511   0.027964785085448 
                 86                 320                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0290282520956225  0.0292200966996006  0.0292865871644684 
                135                  61                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299936183790683 
                 95                 247                 176                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0312345066931086 
                169                 266                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320470415288497  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 66                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0365853658536585  0.0366379310344828  0.0367789392179636 
                183                 179                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0370029389894126  0.0371853546910755 
                 26                 313                 167                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                 89                 123                 231                 348 
 0.0386931402066889  0.0391606080634501  0.0395238095238095  0.0401267159450898 
                178                 237                 147                 121 
 0.0403430749682338  0.0408432147562582  0.0412392825206459  0.0412587412587413 
                185                   9                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0415865384615385 
                198                 235                 298                 319 
 0.0416666666666667    0.04203013481364  0.0422836752899197  0.0423121387283237 
                153                 384                 292                 187 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                209                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0452668098463572  0.0453752181500873  0.0454081632653061 
                328                  54                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761   0.052053981907163  0.0522119900389417 
                343                 154                 167                 394 
 0.0522693757168606  0.0524006824274921  0.0526235972095845  0.0527306967984934 
                165                 285                 204                  78 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0571776155717762 
                141                 375                 283                 143 
 0.0572625698324022  0.0577124691399777  0.0579365729738589   0.058057312988463 
                208                 443                 327                 454 
 0.0594954783436459  0.0601947477131897  0.0604450348721355  0.0605700712589074 
                271                 127                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345   0.077457264957265  0.0775623268698061   0.077792732166891 
                144                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                146                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821542674577818  0.0829190693974945 
                331                  81                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0897435897435897  0.0903323105725727  0.0907393359397794  0.0907575035731301 
                154                 195                  78                 236 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0926889714993804 
                224                 315                 156                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                167                 172                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00897654011461318 
                 49                  41                  54                 242 
0.00921675385217608 0.00992145514675486  0.0103092783505155  0.0105263157894737 
                401                 167                   2                  78 
 0.0111783249552697  0.0116639598405433  0.0118375774260151  0.0121436389221869 
                444                 365                 120                 127 
 0.0128509045539613  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                411                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0143145007984184  0.0146315889810314 
                469                 146                 436                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0198854061341422 
                154                 206                 283                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0220403022670025  0.0220897615708275 
                174                 145                  83                 377 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774   0.023341049382716 
                281                 127                 199                 439 
 0.0233871878883742  0.0234632323008031  0.0235011990407674  0.0236710130391174 
                 76                 136                 209                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                139                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0253712871287129  0.0253881661770877   0.025439388079584 
                153                 297                 203                 323 
 0.0255052935514918  0.0256829707181417  0.0257910706545297   0.026079869600652 
                264                 187                 259                 213 
 0.0261760937213985  0.0264531848242255  0.0265044174029005  0.0266429840142096 
                306                 166                 409                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0272490757223059            0.027375  0.0274423215573179 
                243                 394                  86                 144 
 0.0275999116802826  0.0279437271150511   0.027964785085448  0.0282313475062647 
                320                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617   0.028899183763512 
                 65                 289                 290                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0299936183790683 
                 95                 247                 176                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0312345066931086 
                169                 266                 114                 168 
  0.031352533722202   0.031377415351888  0.0315893385982231  0.0320326150262085 
                157                 254                  97                  56 
 0.0320470415288497  0.0320665083135392  0.0325693606755127  0.0331766657450926 
                 66                  58                 166                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0347459003084916 
                235                 183                 180                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0365853658536585  0.0366379310344828  0.0367789392179636 
                183                 179                 119                 148 
 0.0369127516778524  0.0369817341324224  0.0370029389894126  0.0371853546910755 
                 26                 313                 167                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                 89                 123                 231                 348 
 0.0386931402066889  0.0391606080634501  0.0395238095238095  0.0401267159450898 
                178                 237                 147                 121 
 0.0402792897631292  0.0403430749682338  0.0408432147562582  0.0412392825206459 
                213                 185                   9                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0415865384615385  0.0416666666666667    0.04203013481364  0.0422836752899197 
                319                 153                 384                 292 
 0.0423121387283237  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                187                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0435547734271887  0.0436484634957917  0.0437311002558735  0.0438813349814586 
                176                 227                 225                 239 
 0.0439361466262656  0.0441482715535194  0.0442073170731707  0.0443974630021142 
                181                 137                  90                 125 
  0.044525215810995  0.0445749030296677  0.0452668098463572  0.0453752181500873 
                226                 328                  54                 186 
 0.0454081632653061  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                158                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
 0.0470430107526882  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                 76                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494997367035282 
                165                 223                  98                 106 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0512921525370312 
                 37                 509                 224                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761   0.052053981907163 
                410                 343                 154                 167 
 0.0522119900389417  0.0522693757168606  0.0524006824274921  0.0526235972095845 
                394                 165                 285                 204 
 0.0527306967984934   0.053186119873817  0.0538116591928251   0.053840499816244 
                 78                 493                 131                 239 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0571776155717762  0.0572625698324022  0.0577124691399777  0.0579365729738589 
                143                 208                 443                 327 
  0.058057312988463  0.0594954783436459  0.0601947477131897  0.0604450348721355 
                454                 271                 127                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0691271525139389  0.0691703391454302   0.069882777276826 
                282                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0722415428390768  0.0729649936735555  0.0731810490693739 
                125                 123                  72                 147 
 0.0734780628510703  0.0735163861824624  0.0739031028851388   0.074849349825563 
                227                 170                 356                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0761834556584725 
                176                  72                 180                 238 
             0.0765  0.0771307365985345   0.077457264957265  0.0775623268698061 
                206                 144                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0800351802990325 
                292                 146                 126                 151 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0821542674577818 
                174                 331                  81                 205 
 0.0829190693974945  0.0845114315664221  0.0850873264666368  0.0850877192982456 
                 67                 171                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0885896527285613  0.0897435897435897  0.0903323105725727  0.0907393359397794 
                168                 154                 195                  78 
 0.0907575035731301  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                236                 224                 315                 156 
 0.0926889714993804  0.0931930062807673  0.0936348693532846   0.093978102189781 
                144                  55                  98                 173 
 0.0941611024293223  0.0942935459755794  0.0944649446494465  0.0946155169447789 
                197                  92                 140                 163 
 0.0951444859445646  0.0955528846153846  0.0958677685950413  0.0961078221438468 
                209                 167                 172                  80 
 0.0964175143741707  0.0971563981042654  0.0984356197352587  0.0990077653149267 
                149                 169                 295                 185 
  0.100058147336405   0.101239669421488   0.101467214104577   0.102649006622517 
                399                 143                 269                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.105905511811024 
                157                 134                 167                 345 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.114229765013055   0.114525835974502   0.116141117702154   0.117099936431463 
                 73                 198                 230                 174 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.136729555838747   0.145816826598586   0.146203845806626 
                296                 383                 388                 188 
  0.154871196536584   0.172022950473442   0.181258488003622   0.182134570765661 
                210                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488    0.20463712781353 
                211                 262                 218                 276 
  0.234804706537631    0.25564486542374 
                229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> #######################
> 
> ####################################################
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00897654011461318 
                 49                  41                  54                 242 
0.00921675385217608 0.00992145514675486  0.0103092783505155  0.0105263157894737 
                401                 167                   2                  78 
 0.0111783249552697  0.0116639598405433  0.0118375774260151  0.0121436389221869 
                444                 365                 120                 127 
 0.0128509045539613  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                411                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0143145007984184  0.0146315889810314 
                469                 146                 436                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0186451971127152  0.0188848920863309 
                156                 211                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0198854061341422 
                154                 206                 283                 159 
 0.0199234423280911  0.0201068974293713  0.0206237424547284   0.020628078817734 
                511                 259                 141                 328 
 0.0207115701072462  0.0208385638965604   0.020919175911252  0.0211693548387097 
                150                 180                 151                   9 
 0.0211998923863331  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                 56                 450                 247                 273 
 0.0217859707924348  0.0217929668152551  0.0219236493825174  0.0220403022670025 
                291                 174                 145                  83 
 0.0220897615708275  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                377                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
  0.023341049382716  0.0233871878883742  0.0234632323008031  0.0235011990407674 
                439                  76                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0245203969128997 
                 61                 307                 139                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0255052935514918  0.0256829707181417 
                203                 323                 264                 187 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0264531848242255 
                259                 213                 306                 166 
 0.0265044174029005  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                409                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0272490757223059 
                175                 200                 243                 394 
           0.027375  0.0274423215573179  0.0275999116802826  0.0279437271150511 
                 86                 144                 320                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617   0.028899183763512  0.0290282520956225  0.0291580880307162 
                290                 135                  61                 120 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295730980205104 
                174                 331                  95                 247 
 0.0298372513562387  0.0299936183790683  0.0299939283545841  0.0300218340611354 
                176                 326                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609   0.030411877394636 
                375                 245                 169                 266 
 0.0308211473565804  0.0312345066931086   0.031352533722202   0.031377415351888 
                114                 168                 157                 254 
 0.0315893385982231  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                 97                  56                  66                  58 
 0.0325693606755127  0.0326602346996686  0.0331766657450926  0.0332120109190173 
                166                 339                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0343403607911324 
                142                 122                  90                 235 
 0.0344104070499371  0.0345168698109875  0.0347459003084916  0.0348244147157191 
                183                 180                 203                 152 
 0.0348890414092885  0.0349115972430327  0.0350253807106599  0.0351497282512167 
                205                 291                  53                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0365853658536585  0.0366379310344828  0.0367789392179636  0.0369127516778524 
                179                 119                 148                  26 
 0.0369817341324224  0.0370029389894126  0.0371853546910755  0.0373638098364692 
                313                 167                 133                 334 
 0.0373705538045925  0.0375362566114997  0.0378919022889017  0.0381717729784028 
                 13                 260                 114                  89 
 0.0382320029839612  0.0383953168044077  0.0384615384615385  0.0386931402066889 
                123                 231                 348                 178 
 0.0389174319349488  0.0391606080634501  0.0395238095238095  0.0401267159450898 
                158                 237                 147                 121 
 0.0402792897631292  0.0403430749682338  0.0408432147562582  0.0411866985437948 
                213                 185                   9                  56 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0415865384615385  0.0416666666666667    0.04203013481364 
                298                 319                 153                 384 
 0.0422836752899197  0.0423121387283237  0.0426995042379658  0.0431638211196045 
                292                 187                 197                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434699883302045 
                135                 312                 209                 515 
 0.0435029049171036  0.0435547734271887  0.0436484634957917  0.0437311002558735 
                177                 176                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
 0.0443974630021142   0.044525215810995  0.0445749030296677  0.0452668098463572 
                125                 226                 328                  54 
 0.0453752181500873  0.0454081632653061  0.0454771657160357  0.0458015267175573 
                186                 158                 193                  53 
 0.0458288578589331  0.0461725394896719  0.0462850182704019  0.0463034418891804 
                427                 125                 102                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012  0.0470430107526882  0.0472636815920398  0.0473098330241187 
                226                  76                 155                 127 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494997367035282  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                106                  37                 509                 224 
 0.0512921525370312  0.0513173417223751  0.0513616687062777  0.0516417910447761 
                194                 410                 343                 154 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526235972095845  0.0527306967984934 
                165                 285                 204                  78 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0571776155717762 
                141                 375                 283                 143 
 0.0572625698324022  0.0577124691399777  0.0579365729738589  0.0580472177728254 
                208                 443                 327                 215 
  0.058057312988463  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                454                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0691271525139389  0.0691703391454302 
                163                 282                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0722415428390768  0.0729649936735555 
                 76                 125                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761834556584725              0.0765  0.0771307365985345   0.077457264957265 
                238                 206                 144                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0799757649197213 
                214                 292                 146                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0897435897435897  0.0903323105725727 
                110                 168                 154                 195 
 0.0907393359397794  0.0907575035731301  0.0913471466923659  0.0919729186043997 
                 78                 236                 224                 315 
 0.0920472328923033  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                156                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958677685950413 
                163                 209                 167                 172 
 0.0961078221438468  0.0964175143741707  0.0971563981042654  0.0984356197352587 
                 80                 149                 169                 295 
 0.0990077653149267   0.100058147336405   0.101239669421488   0.101467214104577 
                185                 399                 143                 269 
  0.102649006622517    0.10270393092479   0.102815564694717   0.103008945513689 
                184                 157                 134                 167 
  0.105905511811024   0.108005366726297   0.108166470357283   0.109404990403071 
                345                 171                 170                 265 
  0.110151036178433   0.114229765013055   0.114525835974502   0.116141117702154 
                190                  73                 198                 230 
  0.117099936431463   0.119464797706276   0.120465801097577   0.121081745543946 
                174                 199                 328                 102 
             0.1225   0.123858909955167   0.125036689169357   0.125267338832875 
                 73                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.136729555838747   0.145816826598586 
                204                 296                 383                 388 
  0.146203845806626   0.154871196536584   0.172022950473442   0.181258488003622 
                188                 210                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
   0.20463712781353   0.234804706537631    0.25564486542374 
                276                 229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> 
> 
> ##########################
> #GB
> ##########################
> 
> 
> #By country
> country="United Kingdom"

> cntry<-"GB"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00897654011461318 
                 49                  41                  54                 242 
0.00921675385217608 0.00992145514675486  0.0103092783505155  0.0105263157894737 
                401                 167                   2                  78 
 0.0111783249552697  0.0116639598405433  0.0118375774260151  0.0121436389221869 
                444                 365                 120                 127 
 0.0128509045539613  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                411                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0143145007984184  0.0146315889810314 
                469                 146                 436                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0166853053008276  0.0166950069562529    0.01692628480314 
                338                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0175423941191212  0.0177547118273696  0.0178593575592211  0.0180489901160292 
                252                 164                 227                 370 
 0.0180560891279293  0.0180937818552497  0.0182452374563992  0.0186451971127152 
                195                 156                 211                 587 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0198854061341422  0.0199234423280911  0.0201068974293713  0.0206237424547284 
                159                 511                 259                 141 
  0.020628078817734  0.0207115701072462  0.0208385638965604   0.020919175911252 
                328                 150                 180                 151 
 0.0211693548387097  0.0211998923863331  0.0217065004041104  0.0217617659308621 
                  9                  56                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0224536670362744  0.0225645183083367 
                 83                 377                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                  3                  90                 281                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                139                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0253712871287129  0.0253881661770877   0.025439388079584 
                153                 297                 203                 323 
 0.0255052935514918  0.0256829707181417  0.0257910706545297   0.026079869600652 
                264                 187                 259                 213 
 0.0261760937213985  0.0264531848242255  0.0265044174029005  0.0266179390521136 
                306                 166                 409                 231 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0272490757223059            0.027375 
                200                 243                 394                  86 
 0.0274423215573179  0.0275999116802826  0.0279437271150511   0.027964785085448 
                144                 320                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0308211473565804 
                245                 169                 266                 114 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                 97                  56                  66                  58 
 0.0325693606755127  0.0326602346996686  0.0331766657450926  0.0332120109190173 
                166                 339                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0343403607911324 
                142                 122                  90                 235 
 0.0344104070499371  0.0345168698109875  0.0346534653465347  0.0347459003084916 
                183                 180                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0365853658536585   0.036608183005613  0.0366379310344828 
                183                 179                 188                 119 
 0.0367789392179636  0.0369127516778524  0.0369817341324224  0.0370029389894126 
                148                  26                 313                 167 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382320029839612  0.0383953168044077 
                114                  89                 123                 231 
 0.0384615384615385  0.0386931402066889  0.0389174319349488  0.0391606080634501 
                348                 178                 158                 237 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0408432147562582  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                  9                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0415865384615385 
                198                 235                 298                 319 
 0.0416666666666667    0.04203013481364  0.0422836752899197  0.0423121387283237 
                153                 384                 292                 187 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0435547734271887  0.0436484634957917  0.0437311002558735  0.0438813349814586 
                176                 227                 225                 239 
 0.0439361466262656  0.0441482715535194  0.0442073170731707  0.0443974630021142 
                181                 137                  90                 125 
  0.044525215810995  0.0445749030296677  0.0452668098463572  0.0453752181500873 
                226                 328                  54                 186 
 0.0454081632653061  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                158                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
 0.0470430107526882  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                 76                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494997367035282 
                165                 223                  98                 106 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0512921525370312 
                 37                 509                 224                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0519694944571114 
                410                 343                 154                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526235972095845  0.0527306967984934   0.053186119873817 
                285                 204                  78                 493 
 0.0538116591928251   0.053840499816244  0.0541211987798358  0.0541623127830024 
                131                 239                 227                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0551415797317437 
                149                 181                 239                 141 
 0.0552183277853926  0.0555828824397442  0.0568402950626782  0.0571776155717762 
                375                 283                 171                 143 
 0.0572625698324022  0.0577124691399777  0.0579365729738589  0.0580472177728254 
                208                 443                 327                 215 
  0.058057312988463  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                454                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0691271525139389  0.0691703391454302 
                163                 282                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0722415428390768  0.0729649936735555 
                 76                 125                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761834556584725              0.0765  0.0771307365985345  0.0772969491128418 
                238                 206                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 81                 205                  67                 171 
 0.0850873264666368  0.0850877192982456   0.085838779956427  0.0871771217712177 
                181                 166                 169                 137 
 0.0871937608509935  0.0879211175020542  0.0885896527285613  0.0897435897435897 
                330                 110                 168                 154 
 0.0903323105725727  0.0907393359397794  0.0907575035731301  0.0913471466923659 
                195                  78                 236                 224 
 0.0919729186043997  0.0920472328923033  0.0926889714993804  0.0931930062807673 
                315                 156                 144                  55 
 0.0936348693532846   0.093978102189781  0.0941611024293223  0.0942935459755794 
                 98                 173                 197                  92 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0955528846153846 
                140                 163                 209                 167 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0971563981042654 
                172                  80                 149                 169 
 0.0984356197352587  0.0990077653149267   0.100058147336405   0.101239669421488 
                295                 185                 399                 143 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.105905511811024   0.108005366726297   0.108166470357283 
                167                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.123858909955167   0.125036689169357 
                102                  73                 269                 261 
  0.125267338832875   0.126307739369838   0.131510445635971   0.136729555838747 
                175                 204                 296                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.172022950473442 
                388                 188                 210                 232 
  0.181258488003622   0.182134570765661   0.184947958366693   0.185637891520244 
                190                 212                 211                 262 
  0.189697630293488    0.20463712781353   0.234804706537631    0.25564486542374 
                218                 276                 229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00897654011461318 
                 49                  41                  54                 242 
0.00921675385217608 0.00992145514675486  0.0103092783505155  0.0105263157894737 
                401                 167                   2                  78 
 0.0111783249552697  0.0116639598405433  0.0118375774260151  0.0121436389221869 
                444                 365                 120                 127 
 0.0128509045539613  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                411                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0143145007984184  0.0146315889810314 
                469                 146                 436                 487 
   0.01517663563321   0.015375854214123  0.0154054184575264  0.0163213683449771 
                226                  40                 132                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172739541160594  0.0174939864421605 
                262                 273                 230                 536 
 0.0174951994879454  0.0175423941191212  0.0177547118273696  0.0178593575592211 
                463                 252                 164                 227 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0182452374563992 
                370                 195                 156                 211 
 0.0186451971127152  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                587                 242                 154                 206 
 0.0196571428571429  0.0198854061341422  0.0199234423280911  0.0200785994998214 
                283                 159                 511                 248 
 0.0201068974293713  0.0206237424547284   0.020628078817734  0.0207115701072462 
                259                 141                 328                 150 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0211693548387097 
                172                 180                 151                   9 
 0.0211998923863331  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                 56                 450                 247                 273 
 0.0217859707924348  0.0217929668152551  0.0219236493825174  0.0220403022670025 
                291                 174                 145                  83 
 0.0220897615708275  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                377                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234632323008031 
                244                 439                  76                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0255052935514918 
                297                 203                 323                 264 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0264531848242255  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                166                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0275999116802826  0.0279437271150511   0.027964785085448 
                144                 320                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295730980205104  0.0298372513562387 
                331                  95                 247                 176 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0308211473565804 
                245                 169                 266                 114 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                 97                  56                  66                  58 
 0.0325693606755127  0.0326602346996686  0.0331766657450926  0.0332120109190173 
                166                 339                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0343403607911324 
                142                 122                  90                 235 
 0.0344104070499371  0.0345168698109875  0.0346534653465347  0.0347459003084916 
                183                 180                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0365853658536585   0.036608183005613 
                223                 183                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0369127516778524  0.0369817341324224 
                119                 148                  26                 313 
 0.0370029389894126  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                167                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0389174319349488 
                231                 348                 178                 158 
 0.0391606080634501  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                237                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415865384615385  0.0416666666666667    0.04203013481364 
                373                 319                 153                 384 
 0.0422836752899197  0.0423121387283237  0.0425763261129115  0.0426995042379658 
                292                 187                 335                 197 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0452668098463572  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                 54                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513173417223751  0.0513616687062777 
                224                 194                 410                 343 
 0.0516417910447761  0.0519694944571114   0.052053981907163  0.0522055664835289 
                154                 147                 167                 260 
 0.0522119900389417  0.0522693757168606  0.0524006824274921  0.0526235972095845 
                394                 165                 285                 204 
 0.0527306967984934   0.052766292577279   0.053186119873817  0.0538116591928251 
                 78                 135                 493                 131 
  0.053840499816244  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                239                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0552183277853926 
                181                 239                 141                 375 
 0.0555828824397442  0.0568402950626782  0.0571776155717762  0.0572625698324022 
                283                 171                 143                 208 
 0.0577124691399777  0.0579365729738589  0.0580472177728254   0.058057312988463 
                443                 327                 215                 454 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0722415428390768  0.0729649936735555 
                 76                 125                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761834556584725              0.0765  0.0771307365985345  0.0772969491128418 
                238                 206                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 81                 205                  67                 171 
 0.0850873264666368  0.0850877192982456   0.085838779956427  0.0871771217712177 
                181                 166                 169                 137 
 0.0871937608509935  0.0879211175020542  0.0885896527285613  0.0897435897435897 
                330                 110                 168                 154 
 0.0903323105725727  0.0907393359397794  0.0907575035731301  0.0913471466923659 
                195                  78                 236                 224 
 0.0919729186043997  0.0920472328923033  0.0926889714993804  0.0931930062807673 
                315                 156                 144                  55 
 0.0936348693532846   0.093978102189781  0.0941611024293223  0.0942935459755794 
                 98                 173                 197                  92 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0955528846153846 
                140                 163                 209                 167 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0971563981042654 
                172                  80                 149                 169 
 0.0984356197352587  0.0990077653149267   0.100058147336405   0.101239669421488 
                295                 185                 399                 143 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.105905511811024   0.108005366726297   0.108166470357283 
                167                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.123858909955167   0.125036689169357 
                102                  73                 269                 261 
  0.125267338832875   0.126307739369838   0.131510445635971   0.136729555838747 
                175                 204                 296                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.172022950473442 
                388                 188                 210                 232 
  0.181258488003622   0.182134570765661   0.184947958366693   0.185637891520244 
                190                 212                 211                 262 
  0.189697630293488    0.20463712781353   0.234804706537631    0.25564486542374 
                218                 276                 229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00897654011461318 
                 49                  41                  54                 242 
0.00921172575924771 0.00921675385217608 0.00992145514675486  0.0103092783505155 
                272                 401                 167                   2 
 0.0105263157894737  0.0111783249552697  0.0116639598405433  0.0118375774260151 
                 78                 444                 365                 120 
 0.0121436389221869  0.0128509045539613  0.0135111727005023  0.0135225216646034 
                127                 411                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0142175009388916 
                227                 469                 146                 262 
 0.0143145007984184  0.0143663767587997  0.0146315889810314    0.01517663563321 
                436                 317                 487                 226 
  0.015375854214123  0.0154054184575264  0.0163213683449771  0.0163260512097721 
                 40                 132                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
  0.016656038770565  0.0166853053008276  0.0166950069562529    0.01692628480314 
                207                 151                 283                 262 
 0.0172651069685975  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                273                 230                 536                 463 
 0.0175423941191212  0.0177547118273696  0.0178593575592211  0.0180489901160292 
                252                 164                 227                 370 
 0.0180560891279293  0.0180937818552497  0.0182452374563992  0.0182575272261371 
                195                 156                 211                  17 
 0.0186451971127152  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                587                 242                 154                 206 
 0.0196571428571429   0.019878902830464  0.0198854061341422  0.0199234423280911 
                283                 195                 159                 511 
 0.0200785994998214  0.0201068974293713  0.0206237424547284   0.020628078817734 
                248                 259                 141                 328 
 0.0207115701072462  0.0208122398470019  0.0208385638965604   0.020919175911252 
                150                 172                 180                 151 
 0.0210041364278107  0.0211693548387097  0.0211998923863331  0.0217065004041104 
                339                   9                  56                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0224536670362744 
                145                  83                 377                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                 76                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0245203969128997  0.0246305418719212 
                307                 139                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0253712871287129  0.0253881661770877 
                166                 153                 297                 203 
  0.025439388079584  0.0255052935514918  0.0256829707181417  0.0257910706545297 
                323                 264                 187                 259 
  0.026079869600652  0.0261760937213985  0.0264531848242255  0.0265044174029005 
                213                 306                 166                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0274423215573179  0.0275999116802826 
                394                  86                 144                 320 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617   0.028899183763512  0.0290282520956225 
                289                 290                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0312345066931086 
                169                 266                 114                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0325513638418647 
                 56                  66                  58                 181 
 0.0325693606755127  0.0326602346996686  0.0331766657450926  0.0332120109190173 
                166                 339                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0343403607911324 
                142                 122                  90                 235 
 0.0344104070499371  0.0345168698109875  0.0346534653465347  0.0347459003084916 
                183                 180                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0365853658536585   0.036608183005613 
                223                 183                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0369127516778524  0.0369817341324224 
                119                 148                  26                 313 
 0.0370029389894126  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                167                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0389174319349488 
                231                 348                 178                 158 
 0.0391606080634501  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                237                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415865384615385  0.0416666666666667    0.04203013481364 
                373                 319                 153                 384 
 0.0422836752899197  0.0423121387283237  0.0425763261129115  0.0426995042379658 
                292                 187                 335                 197 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0451125472198807  0.0452668098463572  0.0453752181500873  0.0454081632653061 
                311                  54                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0519694944571114   0.052053981907163 
                343                 154                 147                 167 
 0.0522055664835289  0.0522119900389417  0.0522693757168606  0.0524006824274921 
                260                 394                 165                 285 
 0.0526235972095845  0.0527306967984934   0.052766292577279   0.053186119873817 
                204                  78                 135                 493 
 0.0538116591928251   0.053840499816244  0.0541211987798358  0.0541623127830024 
                131                 239                 227                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0551415797317437 
                149                 181                 239                 141 
 0.0552183277853926  0.0555828824397442  0.0568402950626782  0.0571776155717762 
                375                 283                 171                 143 
 0.0572625698324022  0.0577124691399777  0.0579365729738589  0.0580472177728254 
                208                 443                 327                 215 
  0.058057312988463  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                454                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0686325439266616  0.0691271525139389 
                163                 282                 224                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0722415428390768 
                135                  76                 125                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761834556584725              0.0765  0.0771307365985345 
                180                 238                 206                 144 
 0.0772969491128418   0.077457264957265  0.0775623268698061   0.077792732166891 
                275                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                146                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821542674577818  0.0829190693974945 
                331                  81                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0897435897435897  0.0903323105725727  0.0907393359397794  0.0907575035731301 
                154                 195                  78                 236 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0926889714993804 
                224                 315                 156                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                167                 172                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00897654011461318 
                 49                  41                  54                 242 
0.00921172575924771 0.00921675385217608  0.0096013554854803 0.00992145514675486 
                272                 401                 307                 167 
 0.0103092783505155  0.0105263157894737  0.0111783249552697  0.0116639598405433 
                  2                  78                 444                 365 
 0.0118375774260151  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                120                 127                 276                 411 
 0.0135111727005023  0.0135225216646034  0.0139675349188373  0.0140120610145442 
                293                 298                 227                 469 
  0.014044436416185  0.0142175009388916  0.0143145007984184  0.0143663767587997 
                146                 262                 436                 317 
 0.0146315889810314    0.01517663563321   0.015375854214123  0.0154054184575264 
                487                 226                  40                 132 
   0.01551306498995  0.0163213683449771  0.0163260512097721  0.0164196123147092 
                260                 467                 261                 226 
 0.0164333536214242  0.0164978360593875  0.0165365653245686   0.016656038770565 
                 56                 544                 338                 207 
 0.0166853053008276  0.0166950069562529    0.01692628480314  0.0172651069685975 
                151                 283                 262                 273 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0175423941191212 
                230                 536                 463                 252 
 0.0177547118273696  0.0178593575592211  0.0180489901160292  0.0180560891279293 
                164                 227                 370                 195 
 0.0180937818552497  0.0182452374563992  0.0182575272261371  0.0186451971127152 
                156                 211                  17                 587 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0200785994998214 
                195                 159                 511                 248 
 0.0201068974293713  0.0206237424547284   0.020628078817734  0.0207115701072462 
                259                 141                 328                 150 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0217065004041104 
                326                   9                  56                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                145                  83                 377                  20 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234632323008031  0.0235011990407674 
                439                  76                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0245203969128997 
                 61                 307                 139                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0254880694143167  0.0255052935514918 
                203                 323                 179                 264 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0262657244913807  0.0264531848242255  0.0265044174029005  0.0266179390521136 
                371                 166                 409                 231 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0270745772651745  0.0272490757223059 
                200                 243                 210                 394 
           0.027375  0.0274423215573179  0.0275999116802826  0.0279437271150511 
                 86                 144                 320                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617   0.028899183763512  0.0290282520956225  0.0291580880307162 
                290                 135                  61                 120 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295730980205104 
                174                 331                  95                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
  0.030411877394636  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                266                 114                 189                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0325513638418647 
                 56                  66                  58                 181 
 0.0325693606755127  0.0326602346996686  0.0331766657450926  0.0332120109190173 
                166                 339                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0343403607911324 
                142                 122                  90                 235 
 0.0344104070499371  0.0345168698109875  0.0346534653465347  0.0347459003084916 
                183                 180                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0365853658536585   0.036608183005613 
                223                 183                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0369127516778524  0.0369817341324224 
                119                 148                  26                 313 
 0.0370029389894126  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                167                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0389174319349488 
                231                 348                 178                 158 
 0.0391606080634501  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                237                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415865384615385  0.0416666666666667    0.04203013481364 
                373                 319                 153                 384 
 0.0422836752899197  0.0423121387283237  0.0425763261129115  0.0426995042379658 
                292                 187                 335                 197 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0451125472198807  0.0452668098463572  0.0453118266330111  0.0453752181500873 
                311                  54                 310                 186 
 0.0454081632653061  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                158                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
 0.0470430107526882  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                 76                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494997367035282 
                165                 223                  98                 106 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0512921525370312 
                 37                 509                 224                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0519694944571114 
                410                 343                 154                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526235972095845  0.0527306967984934   0.052766292577279 
                285                 204                  78                 135 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0568402950626782 
                141                 375                 283                 171 
 0.0571776155717762  0.0572625698324022  0.0577124691399777  0.0579365729738589 
                143                 208                 443                 327 
 0.0580472177728254   0.058057312988463  0.0594954783436459  0.0601947477131897 
                215                 454                 271                 127 
 0.0603881058119328  0.0604450348721355  0.0605700712589074  0.0605714285714286 
                145                 263                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0645476772616137 
                341                  88                 157                 248 
 0.0646551724137931  0.0649717514124294  0.0654566518632941  0.0659246575342466 
                223                 333                 179                 214 
  0.065989847715736  0.0662208091218068  0.0663316582914573   0.066402490801019 
                104                 154                  50                 108 
 0.0664614270191959  0.0668523676880223  0.0676933491284481   0.067850348763475 
                140                 200                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0686325439266616 
                189                 163                 282                 224 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0800351802990325 
                292                 146                 126                 151 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0821542674577818 
                174                 331                  81                 205 
 0.0829190693974945  0.0845114315664221  0.0850873264666368  0.0850877192982456 
                 67                 171                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0885896527285613  0.0897435897435897  0.0903323105725727  0.0907393359397794 
                168                 154                 195                  78 
 0.0907575035731301  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                236                 224                 315                 156 
 0.0926889714993804  0.0931930062807673  0.0936348693532846   0.093978102189781 
                144                  55                  98                 173 
 0.0941611024293223  0.0942935459755794  0.0944649446494465  0.0946155169447789 
                197                  92                 140                 163 
 0.0951444859445646  0.0955528846153846  0.0958677685950413  0.0961078221438468 
                209                 167                 172                  80 
 0.0964175143741707  0.0971563981042654  0.0984356197352587  0.0990077653149267 
                149                 169                 295                 185 
  0.100058147336405   0.101239669421488   0.101467214104577   0.102649006622517 
                399                 143                 269                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.105905511811024 
                157                 134                 167                 345 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.114229765013055   0.114525835974502   0.116141117702154   0.117099936431463 
                 73                 198                 230                 174 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.136729555838747   0.145816826598586   0.146203845806626 
                296                 383                 388                 188 
  0.154871196536584   0.172022950473442   0.181258488003622   0.182134570765661 
                210                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488    0.20463712781353 
                211                 262                 218                 276 
  0.234804706537631    0.25564486542374 
                229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00897654011461318 
                 49                  41                  54                 242 
0.00921172575924771 0.00921675385217608  0.0096013554854803 0.00992145514675486 
                272                 401                 307                 167 
 0.0103092783505155  0.0105263157894737  0.0111783249552697  0.0116639598405433 
                  2                  78                 444                 365 
 0.0118375774260151  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                120                 127                 276                 411 
 0.0133810487007935  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                255                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314    0.01517663563321   0.015375854214123 
                317                 487                 226                  40 
 0.0154054184575264    0.01551306498995  0.0163213683449771  0.0163260512097721 
                132                 260                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
  0.016656038770565  0.0166853053008276  0.0166950069562529    0.01692628480314 
                207                 151                 283                 262 
 0.0172651069685975  0.0172672341551625  0.0172739541160594  0.0174939864421605 
                273                 316                 230                 536 
 0.0174951994879454  0.0175423941191212  0.0177547118273696  0.0178593575592211 
                463                 252                 164                 227 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0182452374563992 
                370                 195                 156                 211 
 0.0182575272261371  0.0186451971127152  0.0188848920863309  0.0194376952447067 
                 17                 587                 242                 154 
 0.0194924196145943  0.0196571428571429   0.019878902830464  0.0198854061341422 
                206                 283                 195                 159 
 0.0199234423280911  0.0200785994998214  0.0201068974293713  0.0206237424547284 
                511                 248                 259                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211693548387097  0.0211998923863331  0.0215746707761278  0.0217065004041104 
                  9                  56                  28                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                145                  83                 377                  20 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234632323008031  0.0235011990407674 
                439                  76                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0245203969128997 
                 61                 307                 139                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0254880694143167  0.0255052935514918 
                203                 323                 179                 264 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0262657244913807  0.0264531848242255  0.0265044174029005  0.0266179390521136 
                371                 166                 409                 231 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0270745772651745  0.0272490757223059 
                200                 243                 210                 394 
           0.027375  0.0274423215573179  0.0275999116802826  0.0277726199633943 
                 86                 144                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617   0.028899183763512  0.0290282520956225 
                289                 290                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0308783642812435 
                169                 266                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                 97                  56                  66                  58 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0331766657450926 
                181                 166                 339                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0369127516778524  0.0369810052109598  0.0369817341324224 
                168                  26                 198                 313 
 0.0370029389894126  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                167                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0389174319349488 
                231                 348                 178                 158 
 0.0391606080634501  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                237                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415865384615385  0.0416666666666667    0.04203013481364 
                373                 319                 153                 384 
 0.0422836752899197  0.0423121387283237  0.0425763261129115  0.0426995042379658 
                292                 187                 335                 197 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0451125472198807  0.0452668098463572  0.0453118266330111  0.0453752181500873 
                311                  54                 310                 186 
 0.0454081632653061  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                158                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
 0.0470430107526882  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                 76                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494997367035282 
                165                 223                  98                 106 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0512921525370312 
                 37                 509                 224                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0519694944571114 
                410                 343                 154                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526235972095845  0.0527306967984934   0.052766292577279 
                285                 204                  78                 135 
 0.0529417416647984   0.053186119873817  0.0538116591928251   0.053840499816244 
                305                 493                 131                 239 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0568402950626782  0.0571776155717762  0.0572625698324022  0.0577124691399777 
                171                 143                 208                 443 
 0.0579365729738589  0.0580472177728254   0.058057312988463  0.0594954783436459 
                327                 215                 454                 271 
 0.0601947477131897  0.0603881058119328  0.0604450348721355  0.0605700712589074 
                127                 145                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0722415428390768  0.0729649936735555  0.0731810490693739 
                125                 123                  72                 147 
 0.0734780628510703  0.0735163861824624  0.0739031028851388   0.074849349825563 
                227                 170                 356                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0761834556584725 
                176                  72                 180                 238 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0799757649197213 
                214                 292                 146                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0897435897435897  0.0903323105725727 
                110                 168                 154                 195 
 0.0907393359397794  0.0907575035731301  0.0913471466923659  0.0919729186043997 
                 78                 236                 224                 315 
 0.0920472328923033  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                156                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958677685950413 
                163                 209                 167                 172 
 0.0961078221438468  0.0964175143741707  0.0971563981042654  0.0984356197352587 
                 80                 149                 169                 295 
 0.0990077653149267   0.100058147336405   0.101239669421488   0.101467214104577 
                185                 399                 143                 269 
  0.102649006622517    0.10270393092479   0.102815564694717   0.103008945513689 
                184                 157                 134                 167 
  0.105905511811024   0.108005366726297   0.108166470357283   0.109404990403071 
                345                 171                 170                 265 
  0.110151036178433   0.114229765013055   0.114525835974502   0.116141117702154 
                190                  73                 198                 230 
  0.117099936431463   0.119464797706276   0.120465801097577   0.121081745543946 
                174                 199                 328                 102 
             0.1225   0.123858909955167   0.125036689169357   0.125267338832875 
                 73                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.136729555838747   0.145816826598586 
                204                 296                 383                 388 
  0.146203845806626   0.154871196536584   0.172022950473442   0.181258488003622 
                188                 210                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
   0.20463712781353   0.234804706537631    0.25564486542374 
                276                 229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00897654011461318 
                 49                  41                  54                 242 
0.00921172575924771 0.00921675385217608  0.0096013554854803 0.00992145514675486 
                272                 401                 307                 167 
 0.0103092783505155  0.0105263157894737  0.0111783249552697  0.0116639598405433 
                  2                  78                 444                 365 
 0.0118375774260151  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                120                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0135111727005023  0.0135225216646034 
                 23                 255                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0142175009388916 
                227                 469                 146                 262 
 0.0143145007984184  0.0143663767587997  0.0146315889810314    0.01517663563321 
                436                 317                 487                 226 
  0.015375854214123  0.0154054184575264    0.01551306498995  0.0158163905185268 
                 40                 132                 260                 390 
 0.0162093171665603  0.0163213683449771  0.0163260512097721  0.0164196123147092 
                199                 467                 261                 226 
 0.0164333536214242  0.0164978360593875  0.0165365653245686   0.016656038770565 
                 56                 544                 338                 207 
 0.0166853053008276  0.0166950069562529    0.01692628480314  0.0172651069685975 
                151                 283                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0177547118273696  0.0178593575592211  0.0180489901160292 
                252                 164                 227                 370 
 0.0180560891279293  0.0180937818552497  0.0182452374563992  0.0182575272261371 
                195                 156                 211                  17 
 0.0186451971127152  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                587                 242                 154                 206 
 0.0196571428571429   0.019878902830464  0.0198854061341422  0.0199234423280911 
                283                 195                 159                 511 
 0.0200785994998214  0.0201068974293713  0.0206237424547284   0.020628078817734 
                248                 259                 141                 328 
 0.0207115701072462  0.0207501167194065  0.0208122398470019  0.0208385638965604 
                150                 263                 172                 180 
  0.020919175911252  0.0210041364278107  0.0211323866711337  0.0211693548387097 
                151                 339                 326                   9 
 0.0211998923863331  0.0214106769286397  0.0215746707761278  0.0217065004041104 
                 56                 230                  28                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                145                  83                 377                  20 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234632323008031  0.0235011990407674 
                439                  76                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0245203969128997 
                 61                 307                 139                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0253712871287129 
                268                 166                 153                 297 
 0.0253881661770877   0.025439388079584  0.0254880694143167  0.0255052935514918 
                203                 323                 179                 264 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0262657244913807  0.0264531848242255  0.0265044174029005  0.0266179390521136 
                371                 166                 409                 231 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0270745772651745  0.0272490757223059 
                200                 243                 210                 394 
           0.027375  0.0274423215573179  0.0275999116802826  0.0277726199633943 
                 86                 144                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617  0.0287486347324076   0.028899183763512 
                289                 290                 181                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                 95                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0308211473565804 
                245                 169                 266                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0317272248551869 
                250                  97                 229                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0323421107482804 
                 56                  66                  58                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0331766657450926 
                181                 166                 339                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0369127516778524  0.0369810052109598  0.0369817341324224 
                168                  26                 198                 313 
 0.0370029389894126  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                167                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0389174319349488 
                231                 348                 178                 158 
 0.0391606080634501  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                237                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415865384615385  0.0416666666666667    0.04203013481364 
                373                 319                 153                 384 
 0.0422836752899197  0.0423121387283237  0.0425763261129115  0.0426995042379658 
                292                 187                 335                 197 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0436484634957917 
                515                 177                 176                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0451125472198807  0.0452668098463572  0.0453118266330111  0.0453752181500873 
                311                  54                 310                 186 
 0.0454081632653061  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                158                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
 0.0470430107526882  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                 76                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494997367035282 
                165                 223                  98                 106 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0512921525370312 
                 37                 509                 224                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526235972095845  0.0527306967984934 
                165                 285                 204                  78 
  0.052766292577279  0.0529417416647984   0.053186119873817  0.0538116591928251 
                135                 305                 493                 131 
  0.053840499816244  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                239                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0552183277853926 
                181                 239                 141                 375 
 0.0555828824397442  0.0568402950626782  0.0571776155717762  0.0572625698324022 
                283                 171                 143                 208 
 0.0577124691399777  0.0579365729738589  0.0580472177728254   0.058057312988463 
                443                 327                 215                 454 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0722415428390768  0.0729649936735555 
                 76                 125                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761834556584725              0.0765  0.0771307365985345  0.0772969491128418 
                238                 206                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 81                 205                  67                 171 
 0.0850873264666368  0.0850877192982456   0.085838779956427  0.0871771217712177 
                181                 166                 169                 137 
 0.0871937608509935  0.0879211175020542  0.0885896527285613  0.0897435897435897 
                330                 110                 168                 154 
 0.0903323105725727  0.0907393359397794  0.0907575035731301  0.0913471466923659 
                195                  78                 236                 224 
 0.0919729186043997  0.0920472328923033  0.0926889714993804  0.0931930062807673 
                315                 156                 144                  55 
 0.0936348693532846   0.093978102189781  0.0941611024293223  0.0942935459755794 
                 98                 173                 197                  92 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0955528846153846 
                140                 163                 209                 167 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0971563981042654 
                172                  80                 149                 169 
 0.0984356197352587  0.0990077653149267   0.100058147336405   0.101239669421488 
                295                 185                 399                 143 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.105905511811024   0.108005366726297   0.108166470357283 
                167                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.123858909955167   0.125036689169357 
                102                  73                 269                 261 
  0.125267338832875   0.126307739369838   0.131510445635971   0.136729555838747 
                175                 204                 296                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.172022950473442 
                388                 188                 210                 232 
  0.181258488003622   0.182134570765661   0.184947958366693   0.185637891520244 
                190                 212                 211                 262 
  0.189697630293488    0.20463712781353   0.234804706537631    0.25564486542374 
                218                 276                 229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00897654011461318 
                 49                  41                  54                 242 
0.00921172575924771 0.00921675385217608  0.0096013554854803 0.00992145514675486 
                272                 401                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0116639598405433  0.0118375774260151  0.0121436389221869 
                444                 365                 120                 127 
 0.0127263614373815  0.0128509045539613   0.013088276246171  0.0133810487007935 
                276                 411                  23                 255 
 0.0135111727005023  0.0135225216646034  0.0139675349188373  0.0140120610145442 
                293                 298                 227                 469 
  0.014044436416185  0.0142175009388916  0.0143145007984184  0.0143663767587997 
                146                 262                 436                 317 
 0.0146315889810314    0.01517663563321  0.0152375935889236   0.015375854214123 
                487                 226                 174                  40 
 0.0154054184575264   0.015446694767143    0.01551306498995  0.0158163905185268 
                132                 264                 260                 390 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
  0.016656038770565  0.0166853053008276  0.0166950069562529    0.01692628480314 
                207                 151                 283                 262 
 0.0172651069685975  0.0172672341551625  0.0172739541160594  0.0174939864421605 
                273                 316                 230                 536 
 0.0174951994879454  0.0175423941191212  0.0177547118273696  0.0178593575592211 
                463                 252                 164                 227 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0182452374563992 
                370                 195                 156                 211 
 0.0182575272261371  0.0186451971127152  0.0188848920863309  0.0194376952447067 
                 17                 587                 242                 154 
 0.0194924196145943  0.0196571428571429   0.019878902830464  0.0198854061341422 
                206                 283                 195                 159 
 0.0199234423280911  0.0200785994998214  0.0201068974293713  0.0206237424547284 
                511                 248                 259                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211693548387097  0.0211998923863331  0.0214106769286397  0.0215746707761278 
                  9                  56                 230                  28 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0220403022670025  0.0220897615708275 
                174                 145                  83                 377 
 0.0222703371481596  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                 20                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234526191491455 
                244                 439                  76                 222 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                139                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0251836306400839  0.0251931417728382  0.0253712871287129 
                153                 144                 405                 297 
 0.0253881661770877   0.025439388079584  0.0254880694143167  0.0255052935514918 
                203                 323                 179                 264 
 0.0256829707181417  0.0257910706545297   0.026079869600652  0.0261760937213985 
                187                 259                 213                 306 
 0.0262657244913807  0.0264531848242255  0.0265044174029005  0.0266179390521136 
                371                 166                 409                 231 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0270745772651745  0.0272490757223059 
                200                 243                 210                 394 
           0.027375  0.0274423215573179  0.0275999116802826  0.0277726199633943 
                 86                 144                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617  0.0287486347324076   0.028899183763512 
                289                 290                 181                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                 95                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0308211473565804 
                245                 169                 266                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0317272248551869 
                250                  97                 229                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0323421107482804 
                 56                  66                  58                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0331766657450926 
                181                 166                 339                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0369127516778524  0.0369810052109598  0.0369817341324224 
                168                  26                 198                 313 
 0.0370029389894126  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                167                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0389174319349488 
                231                 348                 178                 158 
 0.0391606080634501  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                237                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                373                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425763261129115 
                384                 292                 187                 335 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                209                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0451125472198807  0.0452668098463572  0.0453118266330111 
                328                 311                  54                 310 
 0.0453752181500873  0.0454081632653061  0.0454771657160357  0.0458015267175573 
                186                 158                 193                  53 
 0.0458288578589331  0.0461725394896719  0.0462850182704019  0.0463034418891804 
                427                 125                 102                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012  0.0470430107526882  0.0472636815920398  0.0473098330241187 
                226                  76                 155                 127 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494997367035282  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                106                  37                 509                 224 
 0.0512921525370312  0.0513173417223751  0.0513616687062777  0.0516417910447761 
                194                 410                 343                 154 
 0.0518164504653419  0.0519694944571114   0.052053981907163  0.0522055664835289 
                253                 147                 167                 260 
 0.0522119900389417  0.0522693757168606  0.0524006824274921  0.0526235972095845 
                394                 165                 285                 204 
 0.0527306967984934   0.052766292577279  0.0529417416647984   0.053186119873817 
                 78                 135                 305                 493 
 0.0538116591928251   0.053840499816244  0.0541211987798358  0.0541623127830024 
                131                 239                 227                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0551415797317437 
                149                 181                 239                 141 
 0.0552183277853926  0.0555828824397442  0.0568402950626782  0.0571776155717762 
                375                 283                 171                 143 
 0.0572625698324022  0.0577124691399777  0.0579365729738589  0.0580472177728254 
                208                 443                 327                 215 
  0.058057312988463  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                454                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0686325439266616  0.0691271525139389 
                163                 282                 224                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0722415428390768 
                135                  76                 125                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761834556584725              0.0765  0.0771307365985345 
                180                 238                 206                 144 
 0.0772969491128418   0.077457264957265  0.0775623268698061   0.077792732166891 
                275                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                146                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821542674577818  0.0829190693974945 
                331                  81                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0897435897435897  0.0903323105725727  0.0907393359397794  0.0907575035731301 
                154                 195                  78                 236 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0926889714993804 
                224                 315                 156                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                167                 172                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> 
> 
> ##########################
> #Ireland
> ##########################
> 
> country="Ireland"

> cntry<-"IE"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00897654011461318 
                 49                  41                  54                 242 
0.00921172575924771 0.00921675385217608  0.0096013554854803 0.00992145514675486 
                272                 401                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0116639598405433  0.0118375774260151  0.0121436389221869 
                444                 365                 120                 127 
 0.0127263614373815  0.0128509045539613   0.013088276246171  0.0133810487007935 
                276                 411                  23                 255 
 0.0135111727005023  0.0135225216646034  0.0139675349188373  0.0140120610145442 
                293                 298                 227                 469 
  0.014044436416185  0.0142175009388916  0.0143145007984184  0.0143663767587997 
                146                 262                 436                 317 
 0.0146315889810314    0.01517663563321  0.0152375935889236   0.015375854214123 
                487                 226                 174                  40 
 0.0154054184575264   0.015446694767143    0.01551306498995  0.0158163905185268 
                132                 264                 260                 390 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
  0.016656038770565  0.0166853053008276  0.0166950069562529    0.01692628480314 
                207                 151                 283                 262 
 0.0172651069685975  0.0172672341551625  0.0172739541160594  0.0174939864421605 
                273                 316                 230                 536 
 0.0174951994879454  0.0175423941191212  0.0177547118273696  0.0178593575592211 
                463                 252                 164                 227 
 0.0178794178794179  0.0180489901160292  0.0180560891279293  0.0180937818552497 
                253                 370                 195                 156 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0188848920863309 
                211                  17                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429   0.019878902830464 
                154                 206                 283                 195 
 0.0198854061341422  0.0199234423280911  0.0200785994998214  0.0201068974293713 
                159                 511                 248                 259 
 0.0205553552109629  0.0206237424547284   0.020628078817734  0.0207115701072462 
                344                 141                 328                 150 
 0.0207501167194065  0.0208122398470019  0.0208385638965604   0.020919175911252 
                263                 172                 180                 151 
 0.0210041364278107  0.0211323866711337  0.0211693548387097  0.0211998923863331 
                339                 326                   9                  56 
 0.0214106769286397  0.0215746707761278  0.0217065004041104  0.0217617659308621 
                230                  28                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0224536670362744 
                 83                 377                  20                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0245203969128997 
                 61                 307                 139                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251697962445066  0.0251836306400839 
                268                 166                 153                 144 
 0.0251931417728382  0.0253712871287129  0.0253881661770877   0.025439388079584 
                405                 297                 203                 323 
 0.0254880694143167  0.0255052935514918  0.0256829707181417  0.0257529463116543 
                179                 264                 187                 181 
 0.0257910706545297   0.026079869600652  0.0261760937213985  0.0262657244913807 
                259                 213                 306                 371 
 0.0264531848242255  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                166                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                144                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0308783642812435 
                169                 266                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0317272248551869  0.0320326150262085 
                 97                 229                 135                  56 
 0.0320470415288497  0.0320665083135392  0.0323421107482804  0.0325513638418647 
                 66                  58                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0331766657450926  0.0332120109190173 
                166                 339                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0340900491865305 
                142                 122                  90                 421 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0346534653465347 
                235                 183                 180                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0365088419851683 
                 70                 223                 183                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0369127516778524  0.0369810052109598  0.0369817341324224 
                168                  26                 198                 313 
 0.0370029389894126  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                167                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0389174319349488 
                231                 348                 178                 158 
 0.0391606080634501  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                237                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                373                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425763261129115 
                384                 292                 187                 335 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                209                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0451125472198807  0.0452668098463572  0.0453118266330111 
                328                 311                  54                 310 
 0.0453752181500873  0.0454081632653061  0.0454771657160357  0.0458015267175573 
                186                 158                 193                  53 
 0.0458288578589331  0.0461725394896719  0.0462850182704019  0.0463034418891804 
                427                 125                 102                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012  0.0470430107526882  0.0472636815920398  0.0473098330241187 
                226                  76                 155                 127 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494997367035282  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                106                  37                 509                 224 
 0.0512921525370312  0.0513173417223751  0.0513616687062777  0.0516417910447761 
                194                 410                 343                 154 
 0.0518164504653419  0.0519694944571114   0.052053981907163  0.0522055664835289 
                253                 147                 167                 260 
 0.0522119900389417  0.0522693757168606  0.0524006824274921  0.0526235972095845 
                394                 165                 285                 204 
 0.0527306967984934   0.052766292577279  0.0529417416647984   0.053186119873817 
                 78                 135                 305                 493 
 0.0538116591928251   0.053840499816244  0.0541211987798358  0.0541623127830024 
                131                 239                 227                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0551415797317437 
                149                 181                 239                 141 
 0.0552183277853926  0.0555828824397442  0.0568402950626782  0.0571776155717762 
                375                 283                 171                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0580472177728254   0.058057312988463  0.0594954783436459  0.0601947477131897 
                215                 454                 271                 127 
 0.0603881058119328  0.0604450348721355  0.0605700712589074  0.0605714285714286 
                145                 263                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0645476772616137 
                341                  88                 157                 248 
 0.0646551724137931  0.0649717514124294  0.0654566518632941  0.0659246575342466 
                223                 333                 179                 214 
  0.065989847715736  0.0662208091218068  0.0663316582914573   0.066402490801019 
                104                 154                  50                 108 
 0.0664614270191959  0.0668523676880223  0.0676933491284481   0.067850348763475 
                140                 200                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0686325439266616 
                189                 163                 282                 224 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0800351802990325 
                292                 146                 126                 151 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0821542674577818 
                174                 331                  81                 205 
 0.0829190693974945  0.0845114315664221  0.0850873264666368  0.0850877192982456 
                 67                 171                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0885896527285613  0.0897435897435897  0.0903323105725727  0.0907393359397794 
                168                 154                 195                  78 
 0.0907575035731301  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                236                 224                 315                 156 
 0.0926889714993804  0.0931930062807673  0.0936348693532846   0.093978102189781 
                144                  55                  98                 173 
 0.0941611024293223  0.0942935459755794  0.0944649446494465  0.0946155169447789 
                197                  92                 140                 163 
 0.0951444859445646  0.0955528846153846  0.0958677685950413  0.0961078221438468 
                209                 167                 172                  80 
 0.0964175143741707  0.0971563981042654  0.0984356197352587  0.0990077653149267 
                149                 169                 295                 185 
  0.100058147336405   0.101239669421488   0.101467214104577   0.102649006622517 
                399                 143                 269                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.105905511811024 
                157                 134                 167                 345 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.114229765013055   0.114525835974502   0.116141117702154   0.117099936431463 
                 73                 198                 230                 174 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.136729555838747   0.145816826598586   0.146203845806626 
                296                 383                 388                 188 
  0.154871196536584   0.172022950473442   0.181258488003622   0.182134570765661 
                210                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488    0.20463712781353 
                211                 262                 218                 276 
  0.234804706537631    0.25564486542374 
                229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

 0.0077958894401134 0.00793650793650794 0.00844155844155844 0.00845335003130871 
                 49                  41                  54                 311 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
 0.0096013554854803 0.00992145514675486  0.0103092783505155  0.0104117368670137 
                307                 167                   2                 439 
 0.0105263157894737  0.0108158220024722  0.0111783249552697  0.0116639598405433 
                 78                 206                 444                 365 
 0.0118375774260151  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                120                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0135111727005023  0.0135225216646034 
                 23                 255                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0142175009388916 
                227                 469                 146                 262 
 0.0143145007984184  0.0143663767587997  0.0146315889810314    0.01517663563321 
                436                 317                 487                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0158163905185268  0.0162093171665603  0.0162519045200609 
                260                 390                 199                  23 
 0.0163213683449771  0.0163260512097721  0.0164196123147092  0.0164333536214242 
                467                 261                 226                  56 
 0.0164978360593875  0.0165365653245686   0.016656038770565  0.0166853053008276 
                544                 338                 207                 151 
 0.0166950069562529    0.01692628480314  0.0172651069685975  0.0172672341551625 
                283                 262                 273                 316 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0175423941191212 
                230                 536                 463                 252 
 0.0177547118273696  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                164                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0182452374563992 
                195                 156                 278                 211 
 0.0182575272261371  0.0186451971127152  0.0188848920863309  0.0194376952447067 
                 17                 587                 242                 154 
 0.0194924196145943  0.0196571428571429   0.019878902830464  0.0198854061341422 
                206                 283                 195                 159 
 0.0199234423280911  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                511                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0214106769286397 
                326                   9                  56                 230 
 0.0215746707761278  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                 28                 450                 247                 273 
 0.0217859707924348  0.0217929668152551  0.0219236493825174  0.0220403022670025 
                291                 174                 145                  83 
 0.0220897615708275  0.0222703371481596  0.0224536670362744  0.0225645183083367 
                377                  20                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                  3                  90                 281                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0245203969128997  0.0246305418719212 
                307                 139                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0251836306400839  0.0251931417728382 
                166                 153                 144                 405 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0254880694143167 
                297                 203                 323                 179 
 0.0255052935514918  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                264                 187                 181                 259 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0308783642812435 
                169                 266                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0317272248551869  0.0320326150262085 
                 97                 229                 135                  56 
 0.0320470415288497  0.0320665083135392  0.0323421107482804  0.0325513638418647 
                 66                  58                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0331766657450926  0.0332120109190173 
                166                 339                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0340900491865305 
                142                 122                  90                 421 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0346534653465347 
                235                 183                 180                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0365088419851683 
                 70                 223                 183                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0369127516778524  0.0369810052109598  0.0369817341324224 
                168                  26                 198                 313 
 0.0370029389894126  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                167                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382320029839612 
                260                 114                  89                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0388998035363458 
                231                 348                 178                 201 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0408432147562582 
                121                 213                 185                   9 
 0.0411866985437948  0.0412392825206459  0.0412587412587413  0.0412642669007902 
                 56                 120                 276                 198 
 0.0412852723944195  0.0412961567445365  0.0413082980012114  0.0415865384615385 
                235                 298                 373                 319 
 0.0416666666666667  0.0416754367501579    0.04203013481364  0.0422836752899197 
                153                 233                 384                 292 
 0.0423121387283237  0.0425763261129115  0.0426995042379658  0.0431638211196045 
                187                 335                 197                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434699883302045 
                135                 312                 209                 515 
 0.0435029049171036  0.0435547734271887  0.0436484634957917  0.0437311002558735 
                177                 176                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
 0.0443974630021142   0.044525215810995  0.0445749030296677  0.0451125472198807 
                125                 226                 328                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526235972095845  0.0527306967984934   0.052766292577279 
                285                 204                  78                 135 
 0.0529417416647984   0.053186119873817  0.0538116591928251   0.053840499816244 
                305                 493                 131                 239 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0571776155717762  0.0572625698324022 
                129                 171                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0580472177728254 
                157                 443                 327                 215 
  0.058057312988463  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                454                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0686325439266616  0.0691271525139389 
                163                 282                 224                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0722415428390768 
                135                  76                 125                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761834556584725              0.0765  0.0771307365985345 
                180                 238                 206                 144 
 0.0772969491128418   0.077457264957265  0.0775623268698061   0.077792732166891 
                275                 178                 214                 292 
 0.0795717592592593  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                146                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821542674577818  0.0829190693974945 
                331                  81                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0897435897435897  0.0903323105725727  0.0907393359397794  0.0907575035731301 
                154                 195                  78                 236 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0926889714993804 
                224                 315                 156                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                167                 172                  80                 149 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105905511811024   0.108005366726297 
                134                 167                 345                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.116141117702154   0.117099936431463   0.119464797706276 
                198                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488    0.20463712781353   0.234804706537631 
                262                 218                 276                 229 
   0.25564486542374 
                237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0121436389221869  0.0127263614373815  0.0128509045539613   0.013088276246171 
                127                 276                 411                  23 
 0.0133810487007935  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                255                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314    0.01517663563321  0.0152375935889236 
                317                 487                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0158163905185268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                390                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0177547118273696 
                536                 463                 252                 164 
 0.0178211163416274  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                119                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0182452374563992 
                195                 156                 278                 211 
 0.0182575272261371  0.0186451971127152  0.0188848920863309  0.0194376952447067 
                 17                 587                 242                 154 
 0.0194924196145943  0.0196571428571429  0.0197222222222222   0.019878902830464 
                206                 283                 296                 195 
 0.0198854061341422  0.0199234423280911  0.0200785994998214  0.0201068974293713 
                159                 511                 248                 259 
 0.0205553552109629  0.0206237424547284   0.020628078817734  0.0207115701072462 
                344                 141                 328                 150 
 0.0207501167194065  0.0208122398470019  0.0208385638965604   0.020919175911252 
                263                 172                 180                 151 
 0.0210041364278107  0.0211323866711337  0.0211693548387097  0.0211998923863331 
                339                 326                   9                  56 
 0.0214106769286397  0.0215326155794807  0.0215746707761278  0.0217065004041104 
                230                 124                  28                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                145                  83                 377                  20 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                323                 179                 264                 187 
 0.0257529463116543  0.0257910706545297   0.026079869600652  0.0261760937213985 
                181                 259                 213                 306 
 0.0262657244913807  0.0264531848242255  0.0265044174029005  0.0266179390521136 
                371                 166                 409                 231 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0270745772651745  0.0272490757223059 
                200                 243                 210                 394 
           0.027375  0.0274423215573179  0.0275103163686382  0.0275999116802826 
                 86                 144                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
  0.030411877394636  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                266                 114                 189                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0317272248551869  0.0320326150262085  0.0320470415288497 
                229                 135                  56                  66 
 0.0320665083135392  0.0323421107482804  0.0325513638418647  0.0325693606755127 
                 58                 421                 181                 166 
 0.0326602346996686  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                339                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0346534653465347  0.0347459003084916 
                183                 180                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0365088419851683  0.0365853658536585 
                223                 183                 169                 179 
  0.036608183005613  0.0366379310344828  0.0367789392179636  0.0367839431449881 
                188                 119                 148                 168 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382320029839612  0.0383953168044077 
                114                  89                 123                 231 
 0.0384615384615385  0.0386931402066889  0.0388998035363458  0.0389174319349488 
                348                 178                 201                 158 
 0.0391606080634501  0.0392809587217044  0.0395238095238095  0.0401267159450898 
                237                 232                 147                 121 
 0.0402792897631292  0.0403430749682338  0.0408432147562582  0.0411866985437948 
                213                 185                   9                  56 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0413082980012114  0.0415865384615385  0.0416666666666667 
                298                 373                 319                 153 
 0.0416754367501579    0.04203013481364  0.0422836752899197  0.0423121387283237 
                233                 384                 292                 187 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0435547734271887  0.0436484634957917  0.0437311002558735  0.0438813349814586 
                176                 227                 225                 239 
 0.0439361466262656  0.0441482715535194  0.0442073170731707  0.0443974630021142 
                181                 137                  90                 125 
  0.044525215810995  0.0445749030296677  0.0451125472198807  0.0452668098463572 
                226                 328                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0512921525370312  0.0513173417223751  0.0513616687062777 
                224                 194                 410                 343 
 0.0516417910447761  0.0518164504653419  0.0519694944571114   0.052053981907163 
                154                 253                 147                 167 
 0.0522055664835289  0.0522119900389417  0.0522693757168606  0.0524006824274921 
                260                 394                 165                 285 
 0.0526235972095845  0.0527306967984934   0.052766292577279  0.0529417416647984 
                204                  78                 135                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0541211987798358 
                493                 131                 239                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0571776155717762  0.0572625698324022  0.0574494949494949 
                171                 143                 208                 157 
 0.0577124691399777  0.0579365729738589  0.0580472177728254   0.058057312988463 
                443                 327                 215                 454 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0722415428390768  0.0729649936735555 
                 76                 125                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761834556584725              0.0765  0.0771307365985345  0.0772969491128418 
                238                 206                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 81                 205                  67                 171 
 0.0850873264666368  0.0850877192982456   0.085838779956427  0.0871771217712177 
                181                 166                 169                 137 
 0.0871937608509935  0.0879211175020542  0.0885896527285613  0.0897435897435897 
                330                 110                 168                 154 
 0.0903323105725727  0.0907393359397794  0.0907575035731301  0.0913471466923659 
                195                  78                 236                 224 
 0.0919729186043997  0.0920472328923033  0.0926889714993804  0.0931930062807673 
                315                 156                 144                  55 
 0.0936348693532846   0.093978102189781  0.0941611024293223  0.0942935459755794 
                 98                 173                 197                  92 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0955528846153846 
                140                 163                 209                 167 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0971563981042654 
                172                  80                 149                 169 
 0.0984356197352587  0.0990077653149267   0.100058147336405   0.101239669421488 
                295                 185                 399                 143 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.105905511811024   0.108005366726297   0.108166470357283 
                167                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.123858909955167   0.125036689169357 
                102                  73                 269                 261 
  0.125267338832875   0.126307739369838   0.131510445635971   0.136729555838747 
                175                 204                 296                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.172022950473442 
                388                 188                 210                 232 
  0.181258488003622   0.182134570765661   0.184947958366693   0.185637891520244 
                190                 212                 211                 262 
  0.189697630293488    0.20463712781353   0.234804706537631    0.25564486542374 
                218                 276                 229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0121436389221869  0.0127263614373815  0.0128509045539613   0.013088276246171 
                127                 276                 411                  23 
 0.0133810487007935  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                255                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314    0.01517663563321  0.0152375935889236 
                317                 487                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0158163905185268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                390                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0188848920863309 
                211                  17                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211693548387097  0.0211998923863331  0.0214106769286397  0.0215326155794807 
                  9                  56                 230                 124 
 0.0215746707761278  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                 28                 450                 247                 273 
 0.0217859707924348  0.0217929668152551  0.0219236493825174  0.0220403022670025 
                291                 174                 145                  83 
 0.0220897615708275  0.0222703371481596  0.0224536670362744  0.0225645183083367 
                377                  20                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                  3                  90                 281                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0245203969128997  0.0246305418719212 
                307                 139                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0251836306400839  0.0251931417728382 
                166                 153                 144                 405 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0254880694143167 
                297                 203                 323                 179 
 0.0255052935514918  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                264                 187                 181                 259 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0308211473565804 
                245                 169                 266                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                135                  56                  66                  58 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346534653465347  0.0347459003084916 
                180                 135                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0365088419851683  0.0365853658536585 
                223                 183                 169                 179 
  0.036608183005613  0.0366379310344828  0.0367789392179636  0.0367839431449881 
                188                 119                 148                 168 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382320029839612  0.0383953168044077 
                114                  89                 123                 231 
 0.0384615384615385  0.0386931402066889  0.0388998035363458  0.0389174319349488 
                348                 178                 201                 158 
 0.0391606080634501  0.0392809587217044  0.0395238095238095  0.0401267159450898 
                237                 232                 147                 121 
 0.0402792897631292  0.0403430749682338  0.0408432147562582  0.0411866985437948 
                213                 185                   9                  56 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0413082980012114  0.0415865384615385  0.0416666666666667 
                298                 373                 319                 153 
 0.0416754367501579    0.04203013481364  0.0422836752899197  0.0423121387283237 
                233                 384                 292                 187 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434699883302045  0.0435029049171036 
                312                 209                 515                 177 
 0.0435547734271887  0.0436484634957917  0.0437311002558735  0.0438813349814586 
                176                 227                 225                 239 
 0.0439361466262656  0.0441482715535194  0.0442073170731707  0.0443974630021142 
                181                 137                  90                 125 
  0.044525215810995  0.0445749030296677  0.0448607345329061  0.0451125472198807 
                226                 328                 322                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526235972095845  0.0527306967984934   0.052766292577279 
                285                 204                  78                 135 
 0.0529417416647984   0.053186119873817  0.0538116591928251   0.053840499816244 
                305                 493                 131                 239 
 0.0538555691554468  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                163                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0552183277853926 
                181                 239                 141                 375 
 0.0555828824397442  0.0557219892150989  0.0568402950626782  0.0571776155717762 
                283                 129                 171                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0580472177728254   0.058057312988463  0.0594954783436459  0.0601947477131897 
                215                 454                 271                 127 
 0.0603881058119328  0.0604450348721355  0.0605700712589074  0.0605714285714286 
                145                 263                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0645476772616137 
                341                  88                 157                 248 
 0.0646551724137931  0.0649717514124294  0.0654566518632941  0.0659246575342466 
                223                 333                 179                 214 
  0.065989847715736  0.0662208091218068  0.0663316582914573   0.066402490801019 
                104                 154                  50                 108 
 0.0664614270191959  0.0668523676880223  0.0676933491284481   0.067850348763475 
                140                 200                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0686325439266616 
                189                 163                 282                 224 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761834556584725              0.0765 
                 72                 180                 238                 206 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0795717592592593  0.0799757649197213  0.0800351802990325 
                292                 146                 126                 151 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0821542674577818 
                174                 331                  81                 205 
 0.0829190693974945  0.0845114315664221  0.0850873264666368  0.0850877192982456 
                 67                 171                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0885896527285613  0.0897435897435897  0.0903323105725727  0.0906718851924331 
                168                 154                 195                 131 
 0.0907393359397794  0.0907575035731301  0.0913471466923659  0.0919729186043997 
                 78                 236                 224                 315 
 0.0920472328923033  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                156                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958677685950413 
                163                 209                 167                 172 
 0.0961078221438468  0.0964175143741707  0.0968399592252803  0.0971563981042654 
                 80                 149                 195                 169 
 0.0984356197352587  0.0990077653149267   0.100058147336405   0.101239669421488 
                295                 185                 399                 143 
  0.101467214104577   0.102649006622517    0.10270393092479   0.102815564694717 
                269                 184                 157                 134 
  0.103008945513689   0.105905511811024   0.108005366726297   0.108166470357283 
                167                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.123858909955167   0.125036689169357 
                102                  73                 269                 261 
  0.125267338832875   0.126307739369838   0.131510445635971   0.136729555838747 
                175                 204                 296                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.172022950473442 
                388                 188                 210                 232 
  0.181258488003622   0.182134570765661   0.184947958366693   0.185637891520244 
                190                 212                 211                 262 
  0.189697630293488    0.20463712781353   0.234804706537631    0.25564486542374 
                218                 276                 229                 237 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0121436389221869  0.0127263614373815  0.0128509045539613   0.013088276246171 
                127                 276                 411                  23 
 0.0133810487007935  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                255                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314    0.01517663563321  0.0152375935889236 
                317                 487                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0158163905185268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                390                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0188848920863309 
                211                  17                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211693548387097  0.0211998923863331  0.0214106769286397  0.0215326155794807 
                  9                  56                 230                 124 
 0.0215746707761278  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                 28                 450                 247                 273 
 0.0217859707924348  0.0217929668152551  0.0219236493825174  0.0220403022670025 
                291                 174                 145                  83 
 0.0220897615708275  0.0222703371481596  0.0224536670362744  0.0225645183083367 
                377                  20                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                  3                  90                 281                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0245203969128997  0.0246305418719212 
                307                 139                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0251836306400839  0.0251931417728382 
                166                 153                 144                 405 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0254880694143167 
                297                 203                 323                 179 
 0.0255052935514918  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                264                 187                 181                 259 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0308211473565804 
                245                 169                 266                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                135                  56                  66                  58 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346534653465347  0.0347459003084916 
                180                 135                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0365088419851683  0.0365853658536585 
                223                 183                 169                 179 
  0.036608183005613  0.0366379310344828  0.0367789392179636  0.0367839431449881 
                188                 119                 148                 168 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382320029839612  0.0383953168044077 
                114                  89                 123                 231 
 0.0384615384615385  0.0386931402066889  0.0388998035363458  0.0389174319349488 
                348                 178                 201                 158 
 0.0391606080634501  0.0392809587217044  0.0395238095238095  0.0401267159450898 
                237                 232                 147                 121 
 0.0402792897631292  0.0403430749682338  0.0408432147562582  0.0411866985437948 
                213                 185                   9                  56 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0413082980012114  0.0415162454873646  0.0415865384615385 
                298                 373                 368                 319 
 0.0416666666666667  0.0416754367501579    0.04203013481364  0.0422836752899197 
                153                 233                 384                 292 
 0.0423121387283237  0.0425763261129115  0.0426995042379658  0.0431638211196045 
                187                 335                 197                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434699883302045 
                135                 312                 209                 515 
 0.0435029049171036  0.0435547734271887  0.0436484634957917  0.0437311002558735 
                177                 176                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
 0.0443974630021142   0.044525215810995  0.0445749030296677  0.0448607345329061 
                125                 226                 328                 322 
 0.0449438202247191  0.0451125472198807  0.0452668098463572  0.0453118266330111 
                 27                 311                  54                 310 
 0.0453752181500873  0.0454081632653061  0.0454771657160357  0.0458015267175573 
                186                 158                 193                  53 
 0.0458288578589331  0.0461725394896719  0.0462850182704019  0.0463034418891804 
                427                 125                 102                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012  0.0470430107526882  0.0472636815920398  0.0473098330241187 
                226                  76                 155                 127 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494997367035282  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                106                  37                 509                 224 
 0.0512921525370312  0.0513173417223751  0.0513616687062777  0.0516417910447761 
                194                 410                 343                 154 
 0.0518164504653419  0.0519694944571114   0.052053981907163  0.0522055664835289 
                253                 147                 167                 260 
 0.0522119900389417  0.0522693757168606  0.0524006824274921  0.0526235972095845 
                394                 165                 285                 204 
 0.0527306967984934   0.052766292577279  0.0529417416647984   0.053186119873817 
                 78                 135                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0571776155717762  0.0572625698324022  0.0574494949494949 
                171                 143                 208                 157 
 0.0577124691399777  0.0579365729738589  0.0579766536964981  0.0580472177728254 
                443                 327                 225                 215 
  0.058057312988463  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                454                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0686325439266616  0.0691271525139389 
                163                 282                 224                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0722415428390768 
                135                  76                 125                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0799757649197213 
                214                 292                 146                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0897435897435897  0.0903323105725727 
                110                 168                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0913471466923659 
                131                  78                 236                 224 
 0.0919729186043997  0.0920472328923033  0.0926889714993804  0.0931930062807673 
                315                 156                 144                  55 
 0.0936348693532846   0.093978102189781  0.0941611024293223  0.0942935459755794 
                 98                 173                 197                  92 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0955528846153846 
                140                 163                 209                 167 
 0.0958322934863988  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                492                 172                  80                 149 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0990077653149267 
                195                 169                 295                 185 
  0.100058147336405   0.101239669421488   0.101467214104577   0.102649006622517 
                399                 143                 269                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.105905511811024 
                157                 134                 167                 345 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.114229765013055   0.114525835974502   0.116141117702154   0.117099936431463 
                 73                 198                 230                 174 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.136729555838747   0.145816826598586   0.146203845806626 
                296                 383                 388                 188 
  0.154871196536584   0.164057181756297   0.172022950473442   0.181258488003622 
                210                 196                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
  0.203438395415473    0.20463712781353   0.234804706537631    0.25564486542374 
                341                 276                 229                 237 
  0.279759519038076 
                219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0121436389221869  0.0127263614373815  0.0128509045539613   0.013088276246171 
                127                 276                 411                  23 
 0.0133810487007935  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                255                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314    0.01517663563321  0.0152375935889236 
                317                 487                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0158163905185268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                390                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0188848920863309 
                211                  17                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211693548387097  0.0211998923863331  0.0214106769286397  0.0215326155794807 
                  9                  56                 230                 124 
 0.0215746707761278  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                 28                 450                 247                 273 
 0.0217859707924348  0.0217929668152551  0.0219236493825174  0.0220403022670025 
                291                 174                 145                  83 
 0.0220897615708275  0.0222703371481596  0.0224536670362744  0.0225645183083367 
                377                  20                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                  3                  90                 281                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0245203969128997  0.0246305418719212 
                307                 139                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0251836306400839  0.0251931417728382 
                166                 153                 144                 405 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0254880694143167 
                297                 203                 323                 179 
 0.0255052935514918  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                264                 187                 181                 259 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0308211473565804 
                245                 169                 266                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                135                  56                  66                  58 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346534653465347  0.0347459003084916 
                180                 135                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0365088419851683  0.0365853658536585 
                223                 183                 169                 179 
  0.036608183005613  0.0366379310344828  0.0367789392179636  0.0367839431449881 
                188                 119                 148                 168 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                114                  89                   9                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889  0.0388998035363458 
                231                 348                 178                 201 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0408432147562582 
                121                 213                 185                   9 
 0.0411866985437948  0.0412392825206459  0.0412587412587413  0.0412642669007902 
                 56                 120                 276                 198 
 0.0412852723944195  0.0412961567445365  0.0413082980012114  0.0415162454873646 
                235                 298                 373                 368 
 0.0415865384615385  0.0416666666666667  0.0416754367501579    0.04203013481364 
                319                 153                 233                 384 
 0.0422836752899197  0.0423121387283237  0.0425763261129115  0.0426995042379658 
                292                 187                 335                 197 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434476279943636  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                352                 515                 177                 176 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0448607345329061  0.0449438202247191  0.0451125472198807 
                328                 322                  27                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0512921525370312  0.0513173417223751 
                509                 224                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526235972095845  0.0527306967984934   0.052766292577279 
                285                 204                  78                 135 
 0.0529417416647984   0.053186119873817  0.0538116591928251   0.053840499816244 
                305                 493                 131                 239 
 0.0538555691554468  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                163                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0552183277853926 
                181                 239                 141                 375 
 0.0555828824397442  0.0557219892150989  0.0568402950626782  0.0569210866752911 
                283                 129                 171                 220 
 0.0571776155717762  0.0572625698324022  0.0574494949494949  0.0577124691399777 
                143                 208                 157                 443 
 0.0579365729738589  0.0579766536964981  0.0580472177728254   0.058057312988463 
                327                 225                 215                 454 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0722415428390768  0.0729649936735555 
                 76                 125                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761194029850746  0.0761834556584725  0.0763305322128851              0.0765 
                162                 238                 147                 206 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0795717592592593  0.0797656602073006  0.0799757649197213 
                292                 146                 245                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0895895895895896  0.0897435897435897 
                110                 168                 228                 154 
 0.0903323105725727  0.0906718851924331  0.0907393359397794  0.0907575035731301 
                195                 131                  78                 236 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0926889714993804 
                224                 315                 156                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                149                 195                 169                 295 
 0.0990077653149267   0.100058147336405   0.101239669421488   0.101467214104577 
                185                 399                 143                 269 
  0.102649006622517    0.10270393092479   0.102815564694717   0.103008945513689 
                184                 157                 134                 167 
  0.105905511811024   0.108005366726297   0.108166470357283   0.109404990403071 
                345                 171                 170                 265 
  0.110151036178433   0.114229765013055   0.114525835974502   0.114706592610481 
                190                  73                 198                 518 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.123858909955167   0.125036689169357 
                102                  73                 269                 261 
  0.125267338832875   0.126307739369838   0.131510445635971   0.136729555838747 
                175                 204                 296                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.163961038961039 
                388                 188                 210                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0121436389221869  0.0127263614373815  0.0128509045539613   0.013088276246171 
                127                 276                 411                  23 
 0.0133810487007935  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                255                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314    0.01517663563321  0.0152375935889236 
                317                 487                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0158163905185268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                390                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0188848920863309 
                211                  17                 587                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211693548387097  0.0211998923863331  0.0214106769286397  0.0215326155794807 
                  9                  56                 230                 124 
 0.0215746707761278  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                 28                 450                 247                 273 
 0.0217859707924348  0.0217929668152551  0.0219236493825174  0.0220403022670025 
                291                 174                 145                  83 
 0.0220897615708275  0.0222703371481596  0.0224536670362744  0.0225645183083367 
                377                  20                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                  3                  90                 281                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0245203969128997  0.0246305418719212 
                307                 139                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0251836306400839  0.0251931417728382 
                166                 153                 144                 405 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0254880694143167 
                297                 203                 323                 179 
 0.0255052935514918  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                264                 187                 181                 259 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0308211473565804 
                245                 169                 266                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                135                  56                  66                  58 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0326864147088866  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 99                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346534653465347 
                183                 180                 135                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0365088419851683 
                 70                 223                 183                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0369127516778524  0.0369810052109598  0.0369817341324224 
                168                  26                 198                 313 
 0.0370029389894126  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                167                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382165605095541 
                260                 114                  89                   9 
 0.0382320029839612  0.0383953168044077  0.0384615384615385  0.0386931402066889 
                123                 231                 348                 178 
  0.038787023977433  0.0388998035363458  0.0389174319349488  0.0391606080634501 
                413                 201                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415162454873646  0.0415865384615385  0.0416666666666667 
                373                 368                 319                 153 
 0.0416754367501579    0.04203013481364  0.0422836752899197  0.0423121387283237 
                233                 384                 292                 187 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0436484634957917  0.0437311002558735 
                177                 176                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
 0.0443974630021142   0.044525215810995  0.0445749030296677  0.0448607345329061 
                125                 226                 328                 322 
 0.0449438202247191  0.0451125472198807  0.0452668098463572  0.0453118266330111 
                 27                 311                  54                 310 
 0.0453752181500873  0.0454081632653061  0.0454771657160357  0.0458015267175573 
                186                 158                 193                  53 
 0.0458288578589331  0.0461725394896719  0.0462850182704019  0.0463034418891804 
                427                 125                 102                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012  0.0470430107526882  0.0472636815920398  0.0473098330241187 
                226                  76                 155                 127 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494997367035282  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                106                  37                 509                 224 
 0.0511221945137157  0.0512921525370312  0.0513173417223751  0.0513616687062777 
                141                 194                 410                 343 
 0.0516417910447761  0.0518164504653419  0.0519694944571114   0.052053981907163 
                154                 253                 147                 167 
 0.0522055664835289  0.0522119900389417  0.0522693757168606  0.0524006824274921 
                260                 394                 165                 285 
 0.0526235972095845  0.0527306967984934   0.052766292577279  0.0529417416647984 
                204                  78                 135                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538555691554468 
                493                 131                 239                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0571776155717762 
                129                 171                 220                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0579766536964981  0.0580472177728254   0.058057312988463  0.0590868397493286 
                225                 215                 454                 214 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 81                 205                  67                 171 
 0.0850873264666368  0.0850877192982456   0.085838779956427  0.0871771217712177 
                181                 166                 169                 137 
 0.0871937608509935  0.0879211175020542  0.0885896527285613  0.0895895895895896 
                330                 110                 168                 228 
 0.0897435897435897  0.0903323105725727  0.0906718851924331  0.0907393359397794 
                154                 195                 131                  78 
 0.0907575035731301  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                236                 224                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0968399592252803 
                172                  80                 149                 195 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.105719237435009   0.105905511811024 
                134                 167                 119                 345 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.114229765013055   0.114525835974502   0.114706592610481   0.116141117702154 
                 73                 198                 518                 230 
  0.117099936431463   0.119464797706276   0.120465801097577   0.121081745543946 
                174                 199                 328                 102 
             0.1225   0.123858909955167   0.125036689169357   0.125267338832875 
                 73                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.135149023638232   0.136729555838747 
                204                 296                 234                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.155465949820789 
                388                 188                 210                 200 
  0.163961038961039   0.164057181756297   0.172022950473442   0.181258488003622 
                210                 196                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
  0.203438395415473    0.20463712781353   0.205955334987593   0.234804706537631 
                341                 276                 319                 229 
   0.25564486542374   0.261106454316848   0.279759519038076 
                237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> 
> 
> ##########################
> #Italy
> ##########################
> 
> country="Italy"

> cntry<-"IT"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0119585886330023  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 97                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0135111727005023  0.0135225216646034 
                 23                 255                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0142175009388916 
                227                 469                 146                 262 
 0.0143145007984184  0.0143663767587997  0.0146315889810314    0.01517663563321 
                436                 317                 487                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0162093171665603 
                260                  33                 390                 199 
 0.0162519045200609  0.0163213683449771  0.0163260512097721  0.0164196123147092 
                 23                 467                 261                 226 
 0.0164333536214242  0.0164978360593875  0.0165365653245686   0.016656038770565 
                 56                 544                 338                 207 
 0.0166853053008276  0.0166950069562529    0.01692628480314  0.0172651069685975 
                151                 283                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176991150442478  0.0177547118273696  0.0178211163416274 
                252                 194                 164                 119 
 0.0178593575592211  0.0178794178794179  0.0180489901160292  0.0180560891279293 
                227                 253                 370                 195 
 0.0180937818552497  0.0181434599156118  0.0182452374563992  0.0182575272261371 
                156                 278                 211                  17 
 0.0186451971127152  0.0186999343401182  0.0188848920863309  0.0194376952447067 
                587                 148                 242                 154 
 0.0194924196145943  0.0196571428571429  0.0197222222222222   0.019878902830464 
                206                 283                 296                 195 
 0.0198854061341422  0.0199234423280911  0.0199362041467305  0.0200785994998214 
                159                 511                 173                 248 
 0.0201068974293713  0.0205553552109629  0.0206237424547284   0.020628078817734 
                259                 344                 141                 328 
 0.0207115701072462  0.0207501167194065  0.0208122398470019  0.0208385638965604 
                150                 263                 172                 180 
  0.020919175911252  0.0210041364278107  0.0211323866711337  0.0211693548387097 
                151                 339                 326                   9 
 0.0211998923863331  0.0214106769286397  0.0215326155794807  0.0215746707761278 
                 56                 230                 124                  28 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0220403022670025  0.0220897615708275 
                174                 145                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                  3                  90                 281                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0245203969128997  0.0246305418719212 
                307                 139                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251697962445066  0.0251836306400839  0.0251931417728382 
                166                 153                 144                 405 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0254880694143167 
                297                 203                 323                 179 
 0.0255052935514918  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                264                 187                 181                 259 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0308211473565804 
                245                 169                 266                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                135                  56                  66                  58 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0326864147088866  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 99                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346534653465347 
                183                 180                 135                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0365088419851683 
                 70                 223                 183                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0386931402066889   0.038787023977433  0.0388998035363458 
                348                 178                 413                 201 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0408432147562582 
                121                 213                 185                   9 
 0.0411866985437948  0.0412392825206459  0.0412587412587413  0.0412642669007902 
                 56                 120                 276                 198 
 0.0412852723944195  0.0412961567445365  0.0413082980012114  0.0415162454873646 
                235                 298                 373                 368 
 0.0415865384615385  0.0416666666666667  0.0416754367501579    0.04203013481364 
                319                 153                 233                 384 
 0.0422836752899197  0.0423121387283237  0.0425763261129115  0.0426995042379658 
                292                 187                 335                 197 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434476279943636  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                352                 515                 177                 176 
 0.0435933286727255  0.0436484634957917  0.0437311002558735  0.0438813349814586 
                 83                 227                 225                 239 
 0.0439361466262656  0.0441482715535194  0.0442073170731707  0.0443974630021142 
                181                 137                  90                 125 
  0.044525215810995  0.0445749030296677  0.0448607345329061  0.0449438202247191 
                226                 328                 322                  27 
 0.0451125472198807  0.0452668098463572  0.0453118266330111  0.0453752181500873 
                311                  54                 310                 186 
 0.0454081632653061  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                158                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
 0.0470430107526882  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                 76                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494997367035282 
                165                 223                  98                 106 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0511221945137157 
                 37                 509                 224                 141 
 0.0512921525370312  0.0513173417223751  0.0513616687062777  0.0516417910447761 
                194                 410                 343                 154 
 0.0518164504653419  0.0519694944571114   0.052053981907163  0.0522055664835289 
                253                 147                 167                 260 
 0.0522119900389417  0.0522693757168606  0.0524006824274921  0.0526157299679707 
                394                 165                 285                 159 
 0.0526235972095845  0.0527306967984934   0.052766292577279  0.0529417416647984 
                204                  78                 135                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538555691554468 
                493                 131                 239                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0571776155717762 
                129                 171                 220                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0579766536964981  0.0580472177728254   0.058057312988463  0.0590868397493286 
                225                 215                 454                 214 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 81                 205                  67                 171 
 0.0850873264666368  0.0850877192982456   0.085838779956427  0.0871771217712177 
                181                 166                 169                 137 
 0.0871937608509935  0.0879211175020542  0.0885896527285613  0.0895895895895896 
                330                 110                 168                 228 
 0.0897435897435897  0.0903323105725727  0.0906718851924331  0.0907393359397794 
                154                 195                 131                  78 
 0.0907575035731301  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                236                 224                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0968399592252803 
                172                  80                 149                 195 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.102649006622517    0.10270393092479 
                143                 269                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024   0.108005366726297   0.108166470357283   0.109404990403071 
                345                 171                 170                 265 
  0.110151036178433   0.114229765013055   0.114525835974502   0.114706592610481 
                190                  73                 198                 518 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.123858909955167   0.125036689169357 
                102                  73                 269                 261 
  0.125267338832875   0.126307739369838   0.131510445635971   0.135149023638232 
                175                 204                 296                 234 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.155465949820789   0.163961038961039   0.164057181756297   0.172022950473442 
                200                 210                 196                 232 
  0.181258488003622   0.182134570765661   0.184947958366693   0.185637891520244 
                190                 212                 211                 262 
  0.189697630293488   0.203438395415473    0.20463712781353   0.205955334987593 
                218                 341                 276                 319 
  0.234804706537631    0.25564486542374   0.261106454316848   0.279759519038076 
                229                 237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0119585886330023  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 97                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                 23                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
   0.01517663563321  0.0152375935889236   0.015375854214123  0.0154054184575264 
                226                 174                  40                 132 
  0.015446694767143    0.01551306498995  0.0157491098329225  0.0158163905185268 
                264                 260                  33                 390 
 0.0159854503685268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                 35                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0214106769286397 
                326                   9                  56                 230 
 0.0215326155794807  0.0215746707761278  0.0217065004041104  0.0217617659308621 
                124                  28                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                323                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0264531848242255  0.0265044174029005 
                306                 371                 166                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0274423215573179  0.0275103163686382 
                394                  86                 144                 398 
 0.0275999116802826  0.0277726199633943  0.0279437271150511   0.027964785085448 
                320                 316                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
 0.0287486347324076   0.028899183763512  0.0290282520956225  0.0291580880307162 
                181                 135                  61                 120 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295295295295295 
                174                 331                  95                 122 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0308783642812435 
                169                 266                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0316678395496129  0.0317272248551869 
                 97                 229                 230                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0323421107482804 
                 56                  66                  58                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0326864147088866 
                181                 166                 339                  99 
 0.0327533265097236  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 13                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346534653465347 
                183                 180                 135                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0365088419851683 
                 70                 223                 183                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0386931402066889   0.038787023977433  0.0388998035363458 
                348                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0408432147562582  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                  9                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594954783436459 
                215                 454                 214                 271 
 0.0601947477131897  0.0603881058119328  0.0604450348721355  0.0605700712589074 
                127                 145                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0718046912398277  0.0722415428390768  0.0729649936735555 
                125                 175                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761194029850746  0.0761834556584725  0.0763305322128851              0.0765 
                162                 238                 147                 206 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0795717592592593  0.0797656602073006  0.0799757649197213 
                292                 146                 245                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0895895895895896  0.0897435897435897 
                110                 168                 228                 154 
 0.0903323105725727  0.0906718851924331  0.0907393359397794  0.0907575035731301 
                195                 131                  78                 236 
 0.0909478746509463  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                184                 224                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0968399592252803 
                172                  80                 149                 195 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024   0.108005366726297   0.108166470357283 
                119                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.135149023638232   0.136729555838747   0.145816826598586   0.146203845806626 
                234                 383                 388                 188 
  0.154871196536584   0.155465949820789   0.163961038961039   0.164057181756297 
                210                 200                 210                 196 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488   0.203438395415473    0.20463712781353 
                262                 218                 341                 276 
  0.205955334987593   0.234804706537631    0.25564486542374   0.261106454316848 
                319                 229                 237                 234 
  0.279759519038076 
                219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0119585886330023  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 97                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                 23                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
   0.01517663563321  0.0152375935889236   0.015375854214123  0.0154054184575264 
                226                 174                  40                 132 
  0.015446694767143    0.01551306498995  0.0157491098329225  0.0158163905185268 
                264                 260                  33                 390 
 0.0159854503685268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                 35                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0214106769286397 
                326                   9                  56                 230 
 0.0215326155794807  0.0215746707761278  0.0217065004041104  0.0217617659308621 
                124                  28                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                323                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0264531848242255  0.0265044174029005 
                306                 371                 166                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0274423215573179  0.0275103163686382 
                394                  86                 144                 398 
 0.0275999116802826  0.0277726199633943  0.0279437271150511   0.027964785085448 
                320                 316                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
 0.0287486347324076   0.028899183763512  0.0290282520956225  0.0291580880307162 
                181                 135                  61                 120 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295295295295295 
                174                 331                  95                 122 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0308783642812435 
                169                 266                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0316678395496129  0.0317272248551869 
                 97                 229                 230                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0323421107482804 
                 56                  66                  58                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0326864147088866 
                181                 166                 339                  99 
 0.0327533265097236  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 13                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346534653465347 
                183                 180                 135                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0365088419851683 
                 70                 223                 183                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0386931402066889   0.038787023977433  0.0388998035363458 
                348                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0408432147562582  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                  9                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594954783436459 
                215                 454                 214                 271 
 0.0601947477131897  0.0603881058119328  0.0604450348721355  0.0605700712589074 
                127                 145                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0718046912398277  0.0722415428390768  0.0729649936735555 
                125                 175                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761194029850746  0.0761834556584725  0.0763305322128851              0.0765 
                162                 238                 147                 206 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0795717592592593  0.0797656602073006  0.0799757649197213 
                292                 146                 245                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0895895895895896  0.0897435897435897 
                110                 168                 228                 154 
 0.0903323105725727  0.0906718851924331  0.0907393359397794  0.0907575035731301 
                195                 131                  78                 236 
 0.0909478746509463  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                184                 224                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0968399592252803 
                172                  80                 149                 195 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024   0.108005366726297   0.108166470357283 
                119                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.135149023638232   0.136729555838747   0.145816826598586   0.146203845806626 
                234                 383                 388                 188 
  0.154871196536584   0.155465949820789   0.163961038961039   0.164057181756297 
                210                 200                 210                 196 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488   0.203438395415473    0.20463712781353 
                262                 218                 341                 276 
  0.205955334987593   0.234804706537631    0.25564486542374   0.261106454316848 
                319                 229                 237                 234 
  0.279759519038076 
                219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0119585886330023  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 97                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                 23                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
   0.01517663563321  0.0152375935889236   0.015375854214123  0.0154054184575264 
                226                 174                  40                 132 
  0.015446694767143    0.01551306498995  0.0157491098329225  0.0158163905185268 
                264                 260                  33                 390 
 0.0159854503685268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                 35                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0214106769286397 
                326                   9                  56                 230 
 0.0215326155794807  0.0215746707761278  0.0217065004041104  0.0217617659308621 
                124                  28                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                323                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0264531848242255  0.0265044174029005 
                306                 371                 166                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0274423215573179  0.0275103163686382 
                394                  86                 144                 398 
 0.0275999116802826  0.0277726199633943  0.0279437271150511   0.027964785085448 
                320                 316                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
 0.0287486347324076   0.028899183763512  0.0290282520956225  0.0291580880307162 
                181                 135                  61                 120 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295295295295295 
                174                 331                  95                 122 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0308783642812435 
                169                 266                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0316678395496129  0.0317272248551869 
                 97                 229                 230                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0323421107482804 
                 56                  66                  58                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0326864147088866 
                181                 166                 339                  99 
 0.0327533265097236  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 13                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346534653465347 
                183                 180                 135                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0365088419851683 
                 70                 223                 183                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0386931402066889   0.038787023977433  0.0388998035363458 
                348                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0408432147562582  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                  9                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594954783436459 
                215                 454                 214                 271 
 0.0601947477131897  0.0603881058119328  0.0604450348721355  0.0605700712589074 
                127                 145                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0718046912398277  0.0722415428390768  0.0729649936735555 
                125                 175                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761194029850746  0.0761834556584725  0.0763305322128851              0.0765 
                162                 238                 147                 206 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0795717592592593  0.0797656602073006  0.0799757649197213 
                292                 146                 245                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0895895895895896  0.0897435897435897 
                110                 168                 228                 154 
 0.0903323105725727  0.0906718851924331  0.0907393359397794  0.0907575035731301 
                195                 131                  78                 236 
 0.0909478746509463  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                184                 224                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0968399592252803 
                172                  80                 149                 195 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024   0.108005366726297   0.108166470357283 
                119                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.135149023638232   0.136729555838747   0.145816826598586   0.146203845806626 
                234                 383                 388                 188 
  0.154871196536584   0.155465949820789   0.163961038961039   0.164057181756297 
                210                 200                 210                 196 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488   0.203438395415473    0.20463712781353 
                262                 218                 341                 276 
  0.205955334987593   0.234804706537631    0.25564486542374   0.261106454316848 
                319                 229                 237                 234 
  0.279759519038076 
                219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0119585886330023  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 97                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                 23                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
   0.01517663563321  0.0152375935889236   0.015375854214123  0.0154054184575264 
                226                 174                  40                 132 
  0.015446694767143    0.01551306498995  0.0157491098329225  0.0158163905185268 
                264                 260                  33                 390 
 0.0159854503685268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                 35                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0214106769286397 
                326                   9                  56                 230 
 0.0215326155794807  0.0215746707761278  0.0217065004041104  0.0217617659308621 
                124                  28                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                323                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0264531848242255  0.0265044174029005 
                306                 371                 166                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0274423215573179  0.0275103163686382 
                394                  86                 144                 398 
 0.0275999116802826  0.0277726199633943  0.0279437271150511   0.027964785085448 
                320                 316                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
 0.0287486347324076   0.028899183763512  0.0290282520956225  0.0291580880307162 
                181                 135                  61                 120 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295295295295295 
                174                 331                  95                 122 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0308211473565804  0.0308783642812435 
                169                 266                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0316678395496129  0.0317272248551869 
                 97                 229                 230                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0323421107482804 
                 56                  66                  58                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0326864147088866 
                181                 166                 339                  99 
 0.0327533265097236  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 13                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346534653465347 
                183                 180                 135                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0365088419851683 
                 70                 223                 183                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0386931402066889   0.038787023977433  0.0388998035363458 
                348                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0408432147562582  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                  9                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594954783436459 
                215                 454                 214                 271 
 0.0601947477131897  0.0603881058119328  0.0604450348721355  0.0605700712589074 
                127                 145                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0718046912398277  0.0722415428390768  0.0729649936735555 
                125                 175                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761194029850746  0.0761834556584725  0.0763305322128851              0.0765 
                162                 238                 147                 206 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0795717592592593  0.0797656602073006  0.0799757649197213 
                292                 146                 245                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0895895895895896  0.0897435897435897 
                110                 168                 228                 154 
 0.0903323105725727  0.0906718851924331  0.0907393359397794  0.0907575035731301 
                195                 131                  78                 236 
 0.0909478746509463  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                184                 224                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0968399592252803 
                172                  80                 149                 195 
 0.0971563981042654  0.0984356197352587  0.0990077653149267   0.100058147336405 
                169                 295                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024   0.108005366726297   0.108166470357283 
                119                 345                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.123858909955167 
                328                 102                  73                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.135149023638232   0.136729555838747   0.145816826598586   0.146203845806626 
                234                 383                 388                 188 
  0.154871196536584   0.155465949820789   0.163961038961039   0.164057181756297 
                210                 200                 210                 196 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488   0.203438395415473    0.20463712781353 
                262                 218                 341                 276 
  0.205955334987593   0.234804706537631    0.25564486542374   0.261106454316848 
                319                 229                 237                 234 
  0.279759519038076 
                219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0119585886330023  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 97                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                 23                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
   0.01517663563321  0.0152375935889236   0.015375854214123  0.0154054184575264 
                226                 174                  40                 132 
  0.015446694767143    0.01551306498995  0.0157491098329225  0.0158163905185268 
                264                 260                  33                 390 
 0.0159854503685268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                 35                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0214106769286397 
                326                   9                  56                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                145                  83                 377                  20 
 0.0223612146352529  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                119                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234526191491455 
                244                 439                  76                 222 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                139                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0251836306400839  0.0251931417728382  0.0253712871287129 
                153                 144                 405                 297 
 0.0253881661770877   0.025439388079584  0.0254880694143167  0.0255052935514918 
                203                 323                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0275103163686382  0.0275999116802826  0.0277726199633943 
                144                 398                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617  0.0287486347324076   0.028899183763512 
                289                 290                 181                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295295295295295  0.0295730980205104  0.0298372513562387 
                 95                 122                 247                 176 
 0.0298965967272362  0.0299936183790683  0.0299939283545841  0.0300218340611354 
                390                 326                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609   0.030411877394636 
                375                 245                 169                 266 
 0.0307638727652658  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                 22                 114                 189                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0320326150262085 
                229                 230                 135                  56 
 0.0320470415288497  0.0320665083135392  0.0323421107482804  0.0325513638418647 
                 66                  58                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346032855644879  0.0346534653465347 
                180                 135                  25                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0363489499192246 
                 70                 223                 183                 123 
 0.0365088419851683  0.0365853658536585   0.036608183005613  0.0366379310344828 
                169                 179                 188                 119 
 0.0367789392179636  0.0367839431449881  0.0368731563421829  0.0369127516778524 
                148                 168                  34                  26 
 0.0369810052109598  0.0369817341324224  0.0370029389894126  0.0370756402620608 
                198                 313                 167                  97 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                114                  89                   9                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889   0.038787023977433 
                231                 348                 178                 413 
 0.0388998035363458  0.0389047933641635  0.0389174319349488  0.0391606080634501 
                201                 155                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415162454873646  0.0415865384615385  0.0416666666666667 
                373                 368                 319                 153 
 0.0416754367501579    0.04203013481364  0.0422836752899197  0.0423121387283237 
                233                 384                 292                 187 
 0.0425136916364987  0.0425763261129115  0.0426995042379658  0.0431638211196045 
                 95                 335                 197                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434476279943636 
                135                 312                 209                 352 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0435933286727255 
                515                 177                 176                  83 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0448607345329061  0.0449438202247191  0.0451125472198807 
                328                 322                  27                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0511221945137157  0.0512921525370312 
                509                 224                 141                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526157299679707  0.0526235972095845 
                165                 285                 159                 204 
 0.0527306967984934   0.052766292577279  0.0529287585522802  0.0529417416647984 
                 78                 135                 158                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538555691554468 
                493                 131                 239                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0571776155717762 
                129                 171                 220                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0579766536964981  0.0580472177728254   0.058057312988463  0.0590868397493286 
                225                 215                 454                 214 
 0.0594161801501251  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                 74                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0686325439266616  0.0691271525139389 
                163                 282                 224                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0718046912398277 
                135                  76                 125                 175 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761194029850746  0.0761834556584725 
                 72                 180                 162                 238 
 0.0763305322128851              0.0765  0.0771307365985345  0.0772969491128418 
                147                 206                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0797656602073006  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                245                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821148001605597  0.0821542674577818 
                331                  81                  35                 205 
 0.0829190693974945  0.0845114315664221  0.0850873264666368  0.0850877192982456 
                 67                 171                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0925431139179014 
                224                 315                 156                 452 
 0.0926889714993804  0.0931930062807673  0.0936348693532846   0.093978102189781 
                144                  55                  98                 173 
 0.0941611024293223  0.0942935459755794  0.0944649446494465  0.0946155169447789 
                197                  92                 140                 163 
 0.0951444859445646  0.0955528846153846  0.0958322934863988  0.0958677685950413 
                209                 167                 492                 172 
 0.0961078221438468  0.0964175143741707  0.0968399592252803  0.0971563981042654 
                 80                 149                 195                 169 
 0.0984356197352587  0.0986763911399244  0.0990077653149267   0.100058147336405 
                295                 119                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024    0.10730054175318   0.108005366726297 
                119                 345                 150                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.114706592610481   0.116141117702154   0.117099936431463 
                198                 518                 230                 174 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.122544159230289   0.123858909955167   0.125036689169357   0.125267338832875 
                 54                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.135149023638232   0.136729555838747 
                204                 296                 234                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.155465949820789 
                388                 188                 210                 200 
  0.163961038961039   0.164057181756297   0.172022950473442   0.181258488003622 
                210                 196                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
  0.203438395415473    0.20463712781353   0.205955334987593   0.234804706537631 
                341                 276                 319                 229 
   0.25564486542374   0.261106454316848   0.279759519038076 
                237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0119585886330023  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 97                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                 23                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
   0.01517663563321  0.0152375935889236   0.015375854214123  0.0154054184575264 
                226                 174                  40                 132 
  0.015446694767143    0.01551306498995  0.0157491098329225  0.0158163905185268 
                264                 260                  33                 390 
 0.0159854503685268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                 35                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0214106769286397 
                326                   9                  56                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                145                  83                 377                  20 
 0.0223612146352529  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                119                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234526191491455 
                244                 439                  76                 222 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                139                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0251836306400839  0.0251931417728382  0.0253712871287129 
                153                 144                 405                 297 
 0.0253881661770877   0.025439388079584  0.0254880694143167  0.0255052935514918 
                203                 323                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0275103163686382  0.0275999116802826  0.0277726199633943 
                144                 398                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617  0.0287486347324076   0.028899183763512 
                289                 290                 181                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295295295295295  0.0295730980205104  0.0298372513562387 
                 95                 122                 247                 176 
 0.0298965967272362  0.0299936183790683  0.0299939283545841  0.0300218340611354 
                390                 326                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609   0.030411877394636 
                375                 245                 169                 266 
 0.0307638727652658  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                 22                 114                 189                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0320326150262085 
                229                 230                 135                  56 
 0.0320470415288497  0.0320665083135392  0.0323421107482804  0.0325513638418647 
                 66                  58                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346032855644879  0.0346534653465347 
                180                 135                  25                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0363489499192246 
                 70                 223                 183                 123 
 0.0365088419851683  0.0365853658536585   0.036608183005613  0.0366379310344828 
                169                 179                 188                 119 
 0.0367789392179636  0.0367839431449881  0.0368731563421829  0.0369127516778524 
                148                 168                  34                  26 
 0.0369810052109598  0.0369817341324224  0.0370029389894126  0.0370756402620608 
                198                 313                 167                  97 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                114                  89                   9                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889   0.038787023977433 
                231                 348                 178                 413 
 0.0388998035363458  0.0389047933641635  0.0389174319349488  0.0391606080634501 
                201                 155                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415162454873646  0.0415865384615385  0.0416666666666667 
                373                 368                 319                 153 
 0.0416754367501579    0.04203013481364  0.0422836752899197  0.0423121387283237 
                233                 384                 292                 187 
 0.0425136916364987  0.0425763261129115  0.0426995042379658  0.0431638211196045 
                 95                 335                 197                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434476279943636 
                135                 312                 209                 352 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0435933286727255 
                515                 177                 176                  83 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0448607345329061  0.0449438202247191  0.0451125472198807 
                328                 322                  27                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0511221945137157  0.0512921525370312 
                509                 224                 141                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526157299679707  0.0526235972095845 
                165                 285                 159                 204 
 0.0527306967984934   0.052766292577279  0.0529287585522802  0.0529417416647984 
                 78                 135                 158                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538555691554468 
                493                 131                 239                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0571776155717762 
                129                 171                 220                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0579766536964981  0.0580472177728254   0.058057312988463  0.0590868397493286 
                225                 215                 454                 214 
 0.0594161801501251  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                 74                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0686325439266616  0.0691271525139389 
                163                 282                 224                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0718046912398277 
                135                  76                 125                 175 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761194029850746  0.0761834556584725 
                 72                 180                 162                 238 
 0.0763305322128851              0.0765  0.0771307365985345  0.0772969491128418 
                147                 206                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0797656602073006  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                245                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821148001605597  0.0821542674577818 
                331                  81                  35                 205 
 0.0829190693974945  0.0845114315664221  0.0850873264666368  0.0850877192982456 
                 67                 171                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0925431139179014 
                224                 315                 156                 452 
 0.0926889714993804  0.0931930062807673  0.0936348693532846   0.093978102189781 
                144                  55                  98                 173 
 0.0941611024293223  0.0942935459755794  0.0944649446494465  0.0946155169447789 
                197                  92                 140                 163 
 0.0951444859445646  0.0955528846153846  0.0958322934863988  0.0958677685950413 
                209                 167                 492                 172 
 0.0961078221438468  0.0964175143741707  0.0968399592252803  0.0971563981042654 
                 80                 149                 195                 169 
 0.0984356197352587  0.0986763911399244  0.0990077653149267   0.100058147336405 
                295                 119                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024    0.10730054175318   0.108005366726297 
                119                 345                 150                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.114706592610481   0.116141117702154   0.117099936431463 
                198                 518                 230                 174 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.122544159230289   0.123858909955167   0.125036689169357   0.125267338832875 
                 54                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.135149023638232   0.136729555838747 
                204                 296                 234                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.155465949820789 
                388                 188                 210                 200 
  0.163961038961039   0.164057181756297   0.172022950473442   0.181258488003622 
                210                 196                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
  0.203438395415473    0.20463712781353   0.205955334987593   0.234804706537631 
                341                 276                 319                 229 
   0.25564486542374   0.261106454316848   0.279759519038076 
                237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> 
> ##########################
> #Netherlands
> ##########################
> 
> country="Netherlands"

> cntry<-"NL"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0119585886330023  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 97                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                 23                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
   0.01517663563321  0.0152375935889236   0.015375854214123  0.0154054184575264 
                226                 174                  40                 132 
  0.015446694767143    0.01551306498995  0.0157491098329225  0.0158163905185268 
                264                 260                  33                 390 
 0.0159854503685268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                 35                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0214106769286397 
                326                   9                  56                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                145                  83                 377                  20 
 0.0223612146352529  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                119                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234526191491455 
                244                 439                  76                 222 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                139                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0251836306400839  0.0251931417728382  0.0253712871287129 
                153                 144                 405                 297 
 0.0253881661770877   0.025439388079584  0.0254880694143167  0.0255052935514918 
                203                 323                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0275103163686382  0.0275999116802826  0.0277726199633943 
                144                 398                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617  0.0287486347324076   0.028899183763512 
                289                 290                 181                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295295295295295  0.0295730980205104  0.0298372513562387 
                 95                 122                 247                 176 
 0.0298965967272362  0.0299936183790683  0.0299939283545841  0.0300218340611354 
                390                 326                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609   0.030411877394636 
                375                 245                 169                 266 
 0.0307638727652658  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                 22                 114                 189                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0320326150262085 
                229                 230                 135                  56 
 0.0320470415288497  0.0320665083135392  0.0323421107482804  0.0325513638418647 
                 66                  58                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346032855644879  0.0346534653465347 
                180                 135                  25                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0363489499192246 
                 70                 223                 183                 123 
 0.0365088419851683  0.0365853658536585   0.036608183005613  0.0366379310344828 
                169                 179                 188                 119 
 0.0367789392179636  0.0367839431449881  0.0368731563421829  0.0369127516778524 
                148                 168                  34                  26 
 0.0369810052109598  0.0369817341324224  0.0370029389894126  0.0370756402620608 
                198                 313                 167                  97 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                114                  89                   9                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889   0.038787023977433 
                231                 348                 178                 413 
 0.0388998035363458  0.0389047933641635  0.0389174319349488  0.0391606080634501 
                201                 155                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415162454873646  0.0415865384615385  0.0416666666666667 
                373                 368                 319                 153 
 0.0416754367501579    0.04203013481364  0.0422836752899197  0.0423121387283237 
                233                 384                 292                 187 
 0.0425136916364987  0.0425763261129115  0.0426995042379658  0.0431638211196045 
                 95                 335                 197                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434476279943636 
                135                 312                 209                 352 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0435933286727255 
                515                 177                 176                  83 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0448607345329061  0.0449438202247191  0.0451125472198807 
                328                 322                  27                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0511221945137157  0.0512921525370312 
                509                 224                 141                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526157299679707  0.0526235972095845 
                165                 285                 159                 204 
 0.0527306967984934   0.052766292577279  0.0529287585522802  0.0529417416647984 
                 78                 135                 158                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538555691554468 
                493                 131                 239                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0571776155717762 
                129                 171                 220                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0579766536964981  0.0580472177728254   0.058057312988463  0.0590868397493286 
                225                 215                 454                 214 
 0.0594161801501251  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                 74                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0686325439266616  0.0691271525139389 
                163                 282                 224                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0718046912398277 
                135                  76                 125                 175 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761194029850746  0.0761834556584725 
                 72                 180                 162                 238 
 0.0763305322128851              0.0765  0.0771307365985345  0.0772969491128418 
                147                 206                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0797656602073006  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                245                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821148001605597  0.0821542674577818 
                331                  81                  35                 205 
 0.0829190693974945  0.0845114315664221  0.0850873264666368  0.0850877192982456 
                 67                 171                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0925431139179014 
                224                 315                 156                 452 
 0.0926889714993804  0.0931930062807673  0.0936348693532846   0.093978102189781 
                144                  55                  98                 173 
 0.0941611024293223  0.0942935459755794  0.0944649446494465  0.0946155169447789 
                197                  92                 140                 163 
 0.0951444859445646  0.0955528846153846  0.0958322934863988  0.0958677685950413 
                209                 167                 492                 172 
 0.0961078221438468  0.0964175143741707  0.0968399592252803  0.0971563981042654 
                 80                 149                 195                 169 
 0.0984356197352587  0.0986763911399244  0.0990077653149267   0.100058147336405 
                295                 119                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024    0.10730054175318   0.108005366726297 
                119                 345                 150                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.114706592610481   0.116141117702154   0.117099936431463 
                198                 518                 230                 174 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.122544159230289   0.123858909955167   0.125036689169357   0.125267338832875 
                 54                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.135149023638232   0.136729555838747 
                204                 296                 234                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.155465949820789 
                388                 188                 210                 200 
  0.163961038961039   0.164057181756297   0.172022950473442   0.181258488003622 
                210                 196                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
  0.203438395415473    0.20463712781353   0.205955334987593   0.234804706537631 
                341                 276                 319                 229 
   0.25564486542374   0.261106454316848   0.279759519038076 
                237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0119585886330023  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 97                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                 23                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
   0.01517663563321  0.0152375935889236   0.015375854214123  0.0154054184575264 
                226                 174                  40                 132 
  0.015446694767143    0.01551306498995  0.0157491098329225  0.0158163905185268 
                264                 260                  33                 390 
 0.0159854503685268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                 35                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0214106769286397 
                326                   9                  56                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                145                  83                 377                  20 
 0.0223612146352529  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                119                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234526191491455 
                244                 439                  76                 222 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                139                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0251836306400839  0.0251931417728382  0.0253712871287129 
                153                 144                 405                 297 
 0.0253881661770877   0.025439388079584  0.0254880694143167  0.0255052935514918 
                203                 323                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0275103163686382  0.0275999116802826  0.0277726199633943 
                144                 398                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617  0.0287486347324076   0.028899183763512 
                289                 290                 181                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295295295295295  0.0295730980205104  0.0298372513562387 
                 95                 122                 247                 176 
 0.0298965967272362  0.0299936183790683  0.0299939283545841  0.0300218340611354 
                390                 326                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609   0.030411877394636 
                375                 245                 169                 266 
 0.0307638727652658  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                 22                 114                 189                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0320326150262085 
                229                 230                 135                  56 
 0.0320470415288497  0.0320665083135392  0.0323421107482804  0.0325513638418647 
                 66                  58                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346032855644879  0.0346534653465347 
                180                 135                  25                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0363489499192246 
                 70                 223                 183                 123 
 0.0365088419851683  0.0365853658536585   0.036608183005613  0.0366379310344828 
                169                 179                 188                 119 
 0.0367789392179636  0.0367839431449881  0.0368731563421829  0.0369127516778524 
                148                 168                  34                  26 
 0.0369810052109598  0.0369817341324224  0.0370029389894126  0.0370756402620608 
                198                 313                 167                  97 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                114                  89                   9                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889   0.038787023977433 
                231                 348                 178                 413 
 0.0388998035363458  0.0389047933641635  0.0389174319349488  0.0391606080634501 
                201                 155                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415162454873646  0.0415865384615385  0.0416666666666667 
                373                 368                 319                 153 
 0.0416754367501579    0.04203013481364  0.0422836752899197  0.0423121387283237 
                233                 384                 292                 187 
 0.0425136916364987  0.0425763261129115  0.0426995042379658  0.0431638211196045 
                 95                 335                 197                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434476279943636 
                135                 312                 209                 352 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0435933286727255 
                515                 177                 176                  83 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0448607345329061  0.0449438202247191  0.0451125472198807 
                328                 322                  27                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0511221945137157  0.0512921525370312 
                509                 224                 141                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526157299679707  0.0526235972095845 
                165                 285                 159                 204 
 0.0527306967984934   0.052766292577279  0.0529287585522802  0.0529417416647984 
                 78                 135                 158                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538555691554468 
                493                 131                 239                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0571776155717762 
                129                 171                 220                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0579766536964981  0.0580472177728254   0.058057312988463  0.0590868397493286 
                225                 215                 454                 214 
 0.0594161801501251  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                 74                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0686325439266616  0.0691271525139389 
                163                 282                 224                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0718046912398277 
                135                  76                 125                 175 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761194029850746  0.0761834556584725 
                 72                 180                 162                 238 
 0.0763305322128851              0.0765  0.0771307365985345  0.0772969491128418 
                147                 206                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0797656602073006  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                245                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821148001605597  0.0821542674577818 
                331                  81                  35                 205 
 0.0829190693974945  0.0845114315664221  0.0850873264666368  0.0850877192982456 
                 67                 171                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0925431139179014 
                224                 315                 156                 452 
 0.0926889714993804  0.0931930062807673  0.0936348693532846   0.093978102189781 
                144                  55                  98                 173 
 0.0941611024293223  0.0942935459755794  0.0944649446494465  0.0946155169447789 
                197                  92                 140                 163 
 0.0951444859445646  0.0955528846153846  0.0958322934863988  0.0958677685950413 
                209                 167                 492                 172 
 0.0961078221438468  0.0964175143741707  0.0968399592252803  0.0971563981042654 
                 80                 149                 195                 169 
 0.0984356197352587  0.0986763911399244  0.0990077653149267   0.100058147336405 
                295                 119                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024    0.10730054175318   0.108005366726297 
                119                 345                 150                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.114706592610481   0.116141117702154   0.117099936431463 
                198                 518                 230                 174 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.122544159230289   0.123858909955167   0.125036689169357   0.125267338832875 
                 54                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.135149023638232   0.136729555838747 
                204                 296                 234                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.155465949820789 
                388                 188                 210                 200 
  0.163961038961039   0.164057181756297   0.172022950473442   0.181258488003622 
                210                 196                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
  0.203438395415473    0.20463712781353   0.205955334987593   0.234804706537631 
                341                 276                 319                 229 
   0.25564486542374   0.261106454316848   0.279759519038076 
                237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00696748506967485  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                206                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923  0.0096013554854803 0.00992145514675486 
                401                 202                 307                 167 
 0.0103092783505155  0.0104117368670137  0.0105263157894737  0.0108158220024722 
                  2                 439                  78                 206 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0119585886330023  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 97                 127                 276                 411 
  0.013088276246171  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                 23                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
   0.01517663563321  0.0152375935889236   0.015375854214123  0.0154054184575264 
                226                 174                  40                 132 
  0.015446694767143    0.01551306498995  0.0157491098329225  0.0158163905185268 
                264                 260                  33                 390 
 0.0159854503685268  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                 35                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686   0.016656038770565  0.0166853053008276  0.0166950069562529 
                338                 207                 151                 283 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0210041364278107 
                172                 180                 151                 339 
 0.0211323866711337  0.0211693548387097  0.0211998923863331  0.0214106769286397 
                326                   9                  56                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                145                  83                 377                  20 
 0.0223612146352529  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                119                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230622919638611  0.0231803430690774 
                 90                 281                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234526191491455 
                244                 439                  76                 222 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                139                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251697962445066  0.0251836306400839  0.0251931417728382  0.0253712871287129 
                153                 144                 405                 297 
 0.0253881661770877   0.025439388079584  0.0254880694143167  0.0255052935514918 
                203                 323                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0275103163686382  0.0275999116802826  0.0277726199633943 
                144                 398                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617  0.0287486347324076   0.028899183763512 
                289                 290                 181                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295295295295295  0.0295730980205104  0.0298372513562387 
                 95                 122                 247                 176 
 0.0298965967272362  0.0299936183790683  0.0299939283545841  0.0300218340611354 
                390                 326                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609   0.030411877394636 
                375                 245                 169                 266 
 0.0307638727652658  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                 22                 114                 189                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0320326150262085 
                229                 230                 135                  56 
 0.0320470415288497  0.0320665083135392  0.0323421107482804  0.0325513638418647 
                 66                  58                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346032855644879  0.0346534653465347 
                180                 135                  25                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0363489499192246 
                 70                 223                 183                 123 
 0.0365088419851683  0.0365853658536585   0.036608183005613  0.0366379310344828 
                169                 179                 188                 119 
 0.0367789392179636  0.0367839431449881  0.0368731563421829  0.0369127516778524 
                148                 168                  34                  26 
 0.0369810052109598  0.0369817341324224  0.0370029389894126  0.0370756402620608 
                198                 313                 167                  97 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                114                  89                   9                 123 
 0.0383953168044077  0.0384615384615385  0.0386931402066889   0.038787023977433 
                231                 348                 178                 413 
 0.0388998035363458  0.0389047933641635  0.0389174319349488  0.0391606080634501 
                201                 155                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0408432147562582  0.0411866985437948  0.0412392825206459 
                185                   9                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415162454873646  0.0415865384615385  0.0416666666666667 
                373                 368                 319                 153 
 0.0416754367501579    0.04203013481364  0.0422836752899197  0.0423121387283237 
                233                 384                 292                 187 
 0.0425136916364987  0.0425763261129115  0.0426995042379658  0.0431638211196045 
                 95                 335                 197                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434476279943636 
                135                 312                 209                 352 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0435933286727255 
                515                 177                 176                  83 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0448607345329061  0.0449438202247191  0.0451125472198807 
                328                 322                  27                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012  0.0470430107526882 
                221                 274                 226                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0502816607552681  0.0509113764927718  0.0511221945137157  0.0512921525370312 
                509                 224                 141                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526157299679707  0.0526235972095845 
                165                 285                 159                 204 
 0.0527306967984934   0.052766292577279  0.0529287585522802  0.0529417416647984 
                 78                 135                 158                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538555691554468 
                493                 131                 239                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0571776155717762 
                129                 171                 220                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0579766536964981  0.0580472177728254   0.058057312988463  0.0590868397493286 
                225                 215                 454                 214 
 0.0594161801501251  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                 74                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645476772616137  0.0646551724137931 
                 88                 157                 248                 223 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676933491284481   0.067850348763475   0.068041136618414 
                200                 256                  74                 189 
 0.0681222707423581  0.0683411214953271  0.0686325439266616  0.0691271525139389 
                163                 282                 224                 160 
 0.0691703391454302   0.069882777276826  0.0701461377870564  0.0702966470190357 
                148                 107                 287                 243 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0718046912398277 
                135                  76                 125                 175 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388   0.074849349825563  0.0753043119455333 
                170                 356                 127                 176 
 0.0755026672137874   0.075534556908353  0.0761194029850746  0.0761834556584725 
                 72                 180                 162                 238 
 0.0763305322128851              0.0765  0.0771307365985345  0.0772969491128418 
                147                 206                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0795717592592593 
                178                 214                 292                 146 
 0.0797656602073006  0.0799757649197213  0.0800351802990325  0.0808438558669541 
                245                 126                 151                 174 
  0.081692573402418  0.0819262038774234  0.0821148001605597  0.0821542674577818 
                331                  81                  35                 205 
 0.0829190693974945  0.0845114315664221  0.0850873264666368  0.0850877192982456 
                 67                 171                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0919729186043997  0.0920472328923033  0.0925431139179014 
                224                 315                 156                 452 
 0.0926889714993804  0.0931930062807673  0.0936348693532846   0.093978102189781 
                144                  55                  98                 173 
 0.0941611024293223  0.0942935459755794  0.0944649446494465  0.0946155169447789 
                197                  92                 140                 163 
 0.0951444859445646  0.0955528846153846  0.0958322934863988  0.0958677685950413 
                209                 167                 492                 172 
 0.0961078221438468  0.0964175143741707  0.0968399592252803  0.0971563981042654 
                 80                 149                 195                 169 
 0.0984356197352587  0.0986763911399244  0.0990077653149267   0.100058147336405 
                295                 119                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024    0.10730054175318   0.108005366726297 
                119                 345                 150                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.114706592610481   0.116141117702154   0.117099936431463 
                198                 518                 230                 174 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.122544159230289   0.123858909955167   0.125036689169357   0.125267338832875 
                 54                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.135149023638232   0.136729555838747 
                204                 296                 234                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.155465949820789 
                388                 188                 210                 200 
  0.163961038961039   0.164057181756297   0.172022950473442   0.181258488003622 
                210                 196                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
  0.203438395415473    0.20463712781353   0.205955334987593   0.234804706537631 
                341                 276                 319                 229 
   0.25564486542374   0.261106454316848   0.279759519038076 
                237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00336376741950985  0.0035218562253988 0.00696748506967485 
                236                 246                  55                 206 
 0.0077958894401134 0.00793650793650794 0.00832376578645235 0.00844155844155844 
                 49                  41                 264                  54 
0.00845335003130871 0.00897654011461318 0.00921172575924771 0.00921675385217608 
                311                 242                 272                 401 
0.00923076923076923  0.0096013554854803 0.00992145514675486  0.0103092783505155 
                202                 307                 167                   2 
 0.0104117368670137  0.0105263157894737  0.0108158220024722  0.0111783249552697 
                439                  78                 206                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0119585886330023 
                216                 365                 120                  97 
 0.0121436389221869  0.0127263614373815  0.0128509045539613   0.013088276246171 
                127                 276                 411                  23 
 0.0133810487007935  0.0134591854570879  0.0135111727005023  0.0135225216646034 
                255                 121                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0142175009388916 
                227                 469                 146                 262 
 0.0143145007984184  0.0143663767587997  0.0146315889810314    0.01517663563321 
                436                 317                 487                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0159854503685268 
                260                  33                 390                  35 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
  0.016656038770565  0.0166853053008276  0.0166950069562529    0.01692628480314 
                207                 151                 283                 262 
 0.0172651069685975  0.0172672341551625  0.0172739541160594  0.0174939864421605 
                273                 316                 230                 536 
 0.0174951994879454  0.0175423941191212  0.0176991150442478  0.0177547118273696 
                463                 252                 194                 164 
 0.0178211163416274  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                119                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0182452374563992 
                195                 156                 278                 211 
 0.0182575272261371  0.0186451971127152  0.0186999343401182  0.0188848920863309 
                 17                 587                 148                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211693548387097  0.0211998923863331  0.0214106769286397  0.0215326155794807 
                  9                  56                 230                 124 
 0.0215746707761278  0.0216911764705882  0.0217065004041104  0.0217617659308621 
                 28                   4                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                323                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0264531848242255  0.0264725347452019 
                306                 371                 166                 156 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0307638727652658 
                245                 169                 266                  22 
 0.0308211473565804  0.0308783642812435  0.0312345066931086   0.031352533722202 
                114                 189                 168                 157 
  0.031377415351888  0.0314051164566628  0.0315893385982231  0.0316351953842119 
                254                 250                  97                 229 
 0.0316678395496129  0.0317272248551869  0.0320326150262085  0.0320470415288497 
                230                 135                  56                  66 
 0.0320665083135392  0.0323421107482804  0.0325513638418647  0.0325693606755127 
                 58                 421                 181                 166 
 0.0326602346996686  0.0326864147088866  0.0327533265097236  0.0331766657450926 
                339                  99                  13                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0345318618725525  0.0346032855644879  0.0346534653465347  0.0347459003084916 
                135                  25                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0363489499192246  0.0365088419851683 
                223                 183                 123                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0386931402066889   0.038787023977433  0.0388998035363458 
                348                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0408432147562582  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                  9                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594161801501251 
                215                 454                 214                  74 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0895895895895896  0.0897435897435897  0.0903323105725727  0.0906718851924331 
                228                 154                 195                 131 
 0.0907393359397794  0.0907575035731301  0.0909478746509463  0.0913471466923659 
                 78                 236                 184                 224 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                149                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626   0.154871196536584   0.155465949820789   0.163961038961039 
                188                 210                 200                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
0.00522193211488251 0.00623755806237558 0.00696748506967485 0.00704322607374672 
                258                 367                 206                 113 
  0.007119524248262  0.0077958894401134 0.00793650793650794 0.00832376578645235 
                208                  49                  41                 264 
0.00844155844155844 0.00845335003130871 0.00897654011461318 0.00921172575924771 
                 54                 311                 242                 272 
0.00921675385217608 0.00923076923076923 0.00947762838880317  0.0096013554854803 
                401                 202                  62                 307 
0.00992145514675486  0.0103092783505155  0.0104117368670137  0.0105202478743335 
                167                   2                 439                 120 
 0.0105263157894737  0.0105684383336754  0.0108158220024722  0.0111783249552697 
                 78                 213                 206                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0119585886330023 
                216                 365                 120                  97 
 0.0121436389221869  0.0127263614373815  0.0128509045539613   0.013088276246171 
                127                 276                 411                  23 
 0.0133810487007935  0.0134591854570879  0.0135111727005023  0.0135225216646034 
                255                 121                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0142175009388916 
                227                 469                 146                 262 
 0.0143145007984184  0.0143663767587997  0.0146315889810314    0.01517663563321 
                436                 317                 487                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0159854503685268 
                260                  33                 390                  35 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
  0.016656038770565  0.0166853053008276  0.0166950069562529    0.01692628480314 
                207                 151                 283                 262 
 0.0172651069685975  0.0172672341551625  0.0172739541160594  0.0174939864421605 
                273                 316                 230                 536 
 0.0174951994879454  0.0175423941191212  0.0176991150442478  0.0177547118273696 
                463                 252                 194                 164 
 0.0178211163416274  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                119                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0182452374563992 
                195                 156                 278                 211 
 0.0182575272261371  0.0186451971127152  0.0186999343401182  0.0188848920863309 
                 17                 587                 148                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211693548387097  0.0211998923863331  0.0214106769286397  0.0215326155794807 
                  9                  56                 230                 124 
 0.0215746707761278  0.0216911764705882  0.0217065004041104  0.0217617659308621 
                 28                   4                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                323                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0264531848242255  0.0264725347452019 
                306                 371                 166                 156 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0307638727652658 
                245                 169                 266                  22 
 0.0308211473565804  0.0308783642812435  0.0312345066931086   0.031352533722202 
                114                 189                 168                 157 
  0.031377415351888  0.0314051164566628  0.0315893385982231  0.0316351953842119 
                254                 250                  97                 229 
 0.0316678395496129  0.0317272248551869  0.0320326150262085  0.0320470415288497 
                230                 135                  56                  66 
 0.0320665083135392  0.0323421107482804  0.0325513638418647  0.0325693606755127 
                 58                 421                 181                 166 
 0.0326602346996686  0.0326864147088866  0.0327533265097236  0.0331766657450926 
                339                  99                  13                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0345318618725525  0.0346032855644879  0.0346534653465347  0.0347459003084916 
                135                  25                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0363489499192246  0.0365088419851683 
                223                 183                 123                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0386931402066889   0.038787023977433  0.0388998035363458 
                348                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0408432147562582  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                  9                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594161801501251 
                215                 454                 214                  74 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0895895895895896  0.0897435897435897  0.0903323105725727  0.0906718851924331 
                228                 154                 195                 131 
 0.0907393359397794  0.0907575035731301  0.0909478746509463  0.0913471466923659 
                 78                 236                 184                 224 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                149                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626   0.154871196536584   0.155465949820789   0.163961038961039 
                188                 210                 200                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
0.00421523730224813 0.00498367417081973 0.00522193211488251 0.00623755806237558 
                311                 193                 258                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
 0.0077958894401134 0.00793650793650794 0.00832376578645235 0.00844155844155844 
                 49                  41                 264                  54 
0.00845335003130871 0.00847457627118644 0.00874488832966342 0.00897654011461318 
                311                  64                 269                 242 
0.00921172575924771 0.00921675385217608 0.00923076923076923 0.00947762838880317 
                272                 401                 202                  62 
0.00959473005871402  0.0096013554854803 0.00992145514675486  0.0103092783505155 
                179                 307                 167                   2 
 0.0104117368670137  0.0105202478743335  0.0105263157894737  0.0105684383336754 
                439                 120                  78                 213 
 0.0108158220024722   0.010862365876275  0.0111783249552697  0.0114810562571757 
                206                 145                 444                 216 
 0.0116639598405433  0.0118375774260151  0.0118885448916409  0.0119585886330023 
                365                 120                 226                  97 
 0.0121436389221869  0.0127263614373815  0.0128509045539613   0.013088276246171 
                127                 276                 411                  23 
 0.0133810487007935  0.0134591854570879  0.0135111727005023  0.0135225216646034 
                255                 121                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0142175009388916 
                227                 469                 146                 262 
 0.0143145007984184  0.0143663767587997  0.0146315889810314    0.01517663563321 
                436                 317                 487                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0159854503685268 
                260                  33                 390                  35 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
  0.016656038770565  0.0166853053008276  0.0166950069562529    0.01692628480314 
                207                 151                 283                 262 
 0.0172651069685975  0.0172672341551625  0.0172739541160594  0.0174939864421605 
                273                 316                 230                 536 
 0.0174951994879454  0.0175423941191212  0.0176991150442478  0.0177547118273696 
                463                 252                 194                 164 
 0.0178211163416274  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                119                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0182452374563992 
                195                 156                 278                 211 
 0.0182575272261371  0.0186451971127152  0.0186999343401182  0.0188848920863309 
                 17                 587                 148                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211693548387097  0.0211998923863331  0.0214106769286397  0.0215326155794807 
                  9                  56                 230                 124 
 0.0215746707761278  0.0216911764705882  0.0217065004041104  0.0217617659308621 
                 28                   4                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                323                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0264531848242255  0.0264725347452019 
                306                 371                 166                 156 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0307638727652658 
                245                 169                 266                  22 
 0.0308211473565804  0.0308783642812435  0.0312345066931086   0.031352533722202 
                114                 189                 168                 157 
  0.031377415351888  0.0314051164566628  0.0315893385982231  0.0316351953842119 
                254                 250                  97                 229 
 0.0316678395496129  0.0317272248551869  0.0320326150262085  0.0320470415288497 
                230                 135                  56                  66 
 0.0320665083135392  0.0323421107482804  0.0325513638418647  0.0325693606755127 
                 58                 421                 181                 166 
 0.0326602346996686  0.0326864147088866  0.0327533265097236  0.0331766657450926 
                339                  99                  13                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0345318618725525  0.0346032855644879  0.0346534653465347  0.0347459003084916 
                135                  25                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0363489499192246  0.0365088419851683 
                223                 183                 123                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0386931402066889   0.038787023977433  0.0388998035363458 
                348                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0408432147562582  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                  9                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594161801501251 
                215                 454                 214                  74 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0895895895895896  0.0897435897435897  0.0903323105725727  0.0906718851924331 
                228                 154                 195                 131 
 0.0907393359397794  0.0907575035731301  0.0909478746509463  0.0913471466923659 
                 78                 236                 184                 224 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                149                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626   0.154871196536584   0.155465949820789   0.163961038961039 
                188                 210                 200                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
0.00421523730224813 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                311                 359                 193                 258 
0.00623755806237558  0.0065345080763583 0.00696748506967485 0.00704322607374672 
                367                 301                 206                 113 
  0.007119524248262 0.00724125750618156  0.0077958894401134 0.00793650793650794 
                208                 211                  49                  41 
0.00832376578645235 0.00844155844155844 0.00845335003130871 0.00847457627118644 
                264                  54                 311                  64 
0.00874488832966342 0.00897654011461318 0.00921172575924771 0.00921675385217608 
                269                 242                 272                 401 
0.00923076923076923 0.00925272484905513 0.00947762838880317 0.00959473005871402 
                202                 312                  62                 179 
 0.0096013554854803 0.00992145514675486  0.0103092783505155  0.0103676377051266 
                307                 167                   2                 315 
 0.0104117368670137  0.0105202478743335  0.0105263157894737  0.0105684383336754 
                439                 120                  78                 213 
 0.0108158220024722   0.010862365876275  0.0111783249552697  0.0114810562571757 
                206                 145                 444                 216 
 0.0116639598405433  0.0118375774260151  0.0118885448916409  0.0119585886330023 
                365                 120                 226                  97 
 0.0120654984199943  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 81                 127                 276                 411 
 0.0130247850278199   0.013088276246171  0.0132057674167902  0.0133810487007935 
                225                  23                 171                 255 
 0.0134591854570879  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                121                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314  0.0147458840372226    0.01517663563321 
                317                 487                 127                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0159854503685268 
                260                  33                 390                  35 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
  0.016656038770565  0.0166853053008276  0.0166950069562529    0.01692628480314 
                207                 151                 283                 262 
 0.0172651069685975  0.0172672341551625  0.0172739541160594  0.0174939864421605 
                273                 316                 230                 536 
 0.0174951994879454  0.0175423941191212  0.0176991150442478  0.0177547118273696 
                463                 252                 194                 164 
 0.0178211163416274  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                119                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0182452374563992 
                195                 156                 278                 211 
 0.0182575272261371  0.0186451971127152  0.0186999343401182  0.0188848920863309 
                 17                 587                 148                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211693548387097  0.0211998923863331  0.0214106769286397  0.0215326155794807 
                  9                  56                 230                 124 
 0.0215746707761278  0.0216911764705882  0.0217065004041104  0.0217617659308621 
                 28                   4                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                281                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251697962445066 
                115                 268                 166                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                323                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0264531848242255  0.0264725347452019 
                306                 371                 166                 156 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0307638727652658 
                245                 169                 266                  22 
 0.0308211473565804  0.0308783642812435  0.0312345066931086   0.031352533722202 
                114                 189                 168                 157 
  0.031377415351888  0.0314051164566628  0.0315893385982231  0.0316351953842119 
                254                 250                  97                 229 
 0.0316678395496129  0.0317272248551869  0.0320326150262085  0.0320470415288497 
                230                 135                  56                  66 
 0.0320665083135392  0.0323421107482804  0.0325513638418647  0.0325693606755127 
                 58                 421                 181                 166 
 0.0326602346996686  0.0326864147088866  0.0327533265097236  0.0331766657450926 
                339                  99                  13                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0345318618725525  0.0346032855644879  0.0346534653465347  0.0347459003084916 
                135                  25                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0363489499192246  0.0365088419851683 
                223                 183                 123                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0386931402066889   0.038787023977433  0.0388998035363458 
                348                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0408432147562582  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                  9                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594161801501251 
                215                 454                 214                  74 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0895895895895896  0.0897435897435897  0.0903323105725727  0.0906718851924331 
                228                 154                 195                 131 
 0.0907393359397794  0.0907575035731301  0.0909478746509463  0.0913471466923659 
                 78                 236                 184                 224 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                149                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626   0.154871196536584   0.155465949820789   0.163961038961039 
                188                 210                 200                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> 
> ##########################
> #Norway
> ##########################
> 
> country="Norway"

> cntry<-"NO"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
0.00421523730224813 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                311                 359                 193                 258 
0.00623755806237558  0.0065345080763583 0.00696748506967485 0.00704322607374672 
                367                 301                 206                 113 
  0.007119524248262 0.00724125750618156  0.0077958894401134 0.00793650793650794 
                208                 211                  49                  41 
0.00824175824175824 0.00832376578645235 0.00844155844155844 0.00845335003130871 
                275                 264                  54                 311 
0.00846023688663283 0.00847457627118644 0.00874488832966342 0.00897654011461318 
                123                  64                 269                 242 
0.00921172575924771 0.00921675385217608 0.00923076923076923 0.00925272484905513 
                272                 401                 202                 312 
0.00947762838880317 0.00959473005871402  0.0096013554854803 0.00992145514675486 
                 62                 179                 307                 167 
 0.0103092783505155  0.0103676377051266  0.0104117368670137  0.0105202478743335 
                  2                 315                 439                 120 
 0.0105263157894737  0.0105684383336754  0.0108158220024722   0.010862365876275 
                 78                 213                 206                 145 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0118885448916409  0.0119585886330023  0.0120654984199943  0.0121436389221869 
                226                  97                  81                 127 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226    0.01517663563321  0.0152375935889236   0.015375854214123 
                127                 226                 174                  40 
 0.0154054184575264   0.015446694767143    0.01551306498995  0.0157491098329225 
                132                 264                 260                  33 
 0.0158163905185268  0.0159854503685268  0.0161589895988113  0.0162093171665603 
                390                  35                 325                 199 
 0.0162519045200609  0.0163213683449771  0.0163260512097721  0.0164196123147092 
                 23                 467                 261                 226 
 0.0164333536214242  0.0164978360593875  0.0165365653245686  0.0165680473372781 
                 56                 544                 338                 215 
  0.016656038770565  0.0166853053008276  0.0166950069562529    0.01692628480314 
                207                 151                 283                 262 
 0.0172651069685975  0.0172672341551625  0.0172739541160594  0.0174939864421605 
                273                 316                 230                 536 
 0.0174951994879454  0.0175423941191212  0.0176991150442478  0.0177547118273696 
                463                 252                 194                 164 
 0.0178211163416274  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                119                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0182452374563992 
                195                 156                 278                 211 
 0.0182575272261371  0.0186451971127152  0.0186999343401182  0.0188848920863309 
                 17                 587                 148                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0210041364278107  0.0211323866711337 
                180                 151                 339                 326 
 0.0211568322981366  0.0211693548387097  0.0211998923863331  0.0212652844231792 
                394                   9                  56                 162 
 0.0214106769286397  0.0215326155794807  0.0215746707761278  0.0216911764705882 
                230                 124                  28                   4 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0220403022670025  0.0220897615708275 
                174                 145                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230622919638611 
                  3                  90                 281                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0245203969128997  0.0246305418719212 
                307                 139                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251256281407035  0.0251697962445066  0.0251836306400839 
                166                 129                 153                 144 
 0.0251931417728382  0.0253712871287129  0.0253881661770877   0.025439388079584 
                405                 297                 203                 323 
 0.0254880694143167  0.0255052935514918  0.0256829707181417  0.0257529463116543 
                179                 264                 187                 181 
 0.0257910706545297  0.0259743135518158   0.026079869600652  0.0261760937213985 
                259                 176                 213                 306 
 0.0262657244913807  0.0264531848242255  0.0264725347452019  0.0265044174029005 
                371                 166                 156                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0274423215573179  0.0275103163686382 
                394                  86                 144                 398 
 0.0275999116802826  0.0277726199633943  0.0279437271150511   0.027964785085448 
                320                 316                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
 0.0287486347324076   0.028899183763512  0.0290282520956225  0.0291580880307162 
                181                 135                  61                 120 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295295295295295 
                174                 331                  95                 122 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609   0.030411877394636  0.0307638727652658  0.0308211473565804 
                169                 266                  22                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                135                  56                  66                  58 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0326864147088866  0.0327533265097236  0.0331766657450926  0.0332120109190173 
                 99                  13                 139                 353 
 0.0333333333333333  0.0339709257842387  0.0340782122905028  0.0340900491865305 
                142                 122                  90                 421 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0345318618725525 
                235                 183                 180                 135 
 0.0346032855644879  0.0346534653465347  0.0347459003084916  0.0348244147157191 
                 25                  25                 203                 152 
 0.0348890414092885  0.0349115972430327  0.0350253807106599  0.0350921393607832 
                205                 291                  53                 160 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0363489499192246  0.0365088419851683  0.0365853658536585 
                183                 123                 169                 179 
  0.036608183005613  0.0366379310344828  0.0367789392179636  0.0367839431449881 
                188                 119                 148                 168 
 0.0368731563421829  0.0369127516778524  0.0369810052109598  0.0369817341324224 
                 34                  26                 198                 313 
 0.0370029389894126  0.0370756402620608  0.0371853546910755  0.0373638098364692 
                167                  97                 133                 334 
 0.0373705538045925  0.0375362566114997  0.0378919022889017  0.0381717729784028 
                 13                 260                 114                  89 
 0.0382165605095541  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                  9                 123                 231                 348 
 0.0386931402066889   0.038787023977433  0.0388998035363458  0.0389047933641635 
                178                 413                 201                 155 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0408432147562582 
                121                 213                 185                   9 
   0.04099560761347  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                104                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594161801501251 
                215                 454                 214                  74 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0895895895895896  0.0897435897435897  0.0903323105725727  0.0906718851924331 
                228                 154                 195                 131 
 0.0907393359397794  0.0907575035731301  0.0909478746509463  0.0913471466923659 
                 78                 236                 184                 224 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                149                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626   0.154871196536584   0.155465949820789   0.163961038961039 
                188                 210                 200                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
0.00421523730224813 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                311                 359                 193                 258 
0.00623755806237558  0.0065345080763583 0.00696748506967485 0.00704322607374672 
                367                 301                 206                 113 
  0.007119524248262 0.00724125750618156  0.0077958894401134 0.00793650793650794 
                208                 211                  49                  41 
0.00824175824175824 0.00832376578645235 0.00844155844155844 0.00845335003130871 
                275                 264                  54                 311 
0.00846023688663283 0.00847457627118644 0.00874488832966342 0.00897654011461318 
                123                  64                 269                 242 
0.00921172575924771 0.00921675385217608 0.00923076923076923 0.00925272484905513 
                272                 401                 202                 312 
0.00947762838880317 0.00959473005871402  0.0096013554854803 0.00965107646622123 
                 62                 179                 307                 179 
0.00992145514675486  0.0100413467217956  0.0103092783505155  0.0103676377051266 
                167                 160                   2                 315 
 0.0104117368670137  0.0105202478743335  0.0105263157894737  0.0105684383336754 
                439                 120                  78                 213 
 0.0108158220024722   0.010862365876275  0.0111783249552697  0.0114810562571757 
                206                 145                 444                 216 
 0.0116639598405433  0.0118375774260151  0.0118885448916409  0.0119585886330023 
                365                 120                 226                  97 
 0.0120654984199943  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 81                 127                 276                 411 
 0.0130247850278199   0.013088276246171  0.0132057674167902  0.0133810487007935 
                225                  23                 171                 255 
 0.0134591854570879  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                121                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314  0.0147458840372226    0.01517663563321 
                317                 487                 127                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0159854503685268 
                260                  33                 390                  35 
 0.0161589895988113  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                325                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0165680473372781   0.016656038770565  0.0166853053008276 
                338                 215                 207                 151 
 0.0166950069562529  0.0167711021009952    0.01692628480314  0.0172651069685975 
                283                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176991150442478  0.0177547118273696  0.0178211163416274 
                252                 194                 164                 119 
 0.0178593575592211  0.0178794178794179  0.0180489901160292  0.0180560891279293 
                227                 253                 370                 195 
 0.0180937818552497  0.0181434599156118  0.0182452374563992  0.0182575272261371 
                156                 278                 211                  17 
 0.0186451971127152  0.0186999343401182  0.0188848920863309  0.0194376952447067 
                587                 148                 242                 154 
 0.0194924196145943  0.0196571428571429  0.0197222222222222   0.019878902830464 
                206                 283                 296                 195 
 0.0198854061341422  0.0199234423280911  0.0199362041467305  0.0200785994998214 
                159                 511                 173                 248 
 0.0201068974293713  0.0205553552109629  0.0206237424547284   0.020628078817734 
                259                 344                 141                 328 
 0.0207115701072462  0.0207501167194065  0.0208122398470019  0.0208385638965604 
                150                 263                 172                 180 
  0.020919175911252  0.0209403397866456  0.0210041364278107  0.0211323866711337 
                151                 190                 339                 326 
 0.0211568322981366  0.0211693548387097  0.0211998923863331  0.0212652844231792 
                394                   9                  56                 162 
 0.0214106769286397  0.0215326155794807  0.0215746707761278  0.0216911764705882 
                230                 124                  28                   4 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0220403022670025  0.0220897615708275 
                174                 145                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0245203969128997 
                 61                 307                 139                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251256281407035  0.0251697962445066 
                268                 166                 129                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254668930390492  0.0254880694143167  0.0255052935514918 
                323                 134                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0274626865671642  0.0275103163686382  0.0275999116802826 
                144                 113                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
  0.030411877394636  0.0307638727652658  0.0308211473565804  0.0308783642812435 
                266                  22                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0316678395496129  0.0317272248551869 
                 97                 229                 230                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0323421107482804 
                 56                  66                  58                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0326864147088866 
                181                 166                 339                  99 
 0.0327533265097236  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 13                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346032855644879 
                183                 180                 135                  25 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0363489499192246  0.0365088419851683  0.0365853658536585   0.036608183005613 
                123                 169                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0367839431449881  0.0368731563421829 
                119                 148                 168                  34 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0370756402620608  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                 97                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382165605095541 
                260                 114                  89                   9 
 0.0382320029839612  0.0383953168044077  0.0384615384615385  0.0385852090032154 
                123                 231                 348                 147 
 0.0386931402066889   0.038787023977433  0.0388998035363458  0.0389047933641635 
                178                 413                 201                 155 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0408432147562582 
                121                 213                 185                   9 
   0.04099560761347  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                104                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594161801501251 
                215                 454                 214                  74 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0895895895895896  0.0897435897435897  0.0903323105725727  0.0906718851924331 
                228                 154                 195                 131 
 0.0907393359397794  0.0907575035731301  0.0909478746509463  0.0913471466923659 
                 78                 236                 184                 224 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                149                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626   0.154871196536584   0.155465949820789   0.163961038961039 
                188                 210                 200                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
0.00421523730224813 0.00448895027624309 0.00459066564651875 0.00490244627116965 
                311                 366                 194                 359 
0.00498367417081973 0.00522193211488251 0.00587199060481503 0.00623755806237558 
                193                 258                 131                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156  0.0077958894401134 0.00793650793650794 0.00824175824175824 
                211                  49                  41                 275 
0.00832376578645235 0.00844155844155844 0.00845335003130871 0.00846023688663283 
                264                  54                 311                 123 
0.00847457627118644 0.00874488832966342 0.00897654011461318 0.00921172575924771 
                 64                 269                 242                 272 
0.00921675385217608 0.00923076923076923 0.00925272484905513 0.00947762838880317 
                401                 202                 312                  62 
0.00959473005871402  0.0096013554854803 0.00965107646622123 0.00992145514675486 
                179                 307                 179                 167 
 0.0100413467217956  0.0103092783505155  0.0103676377051266  0.0104117368670137 
                160                   2                 315                 439 
 0.0105202478743335  0.0105263157894737  0.0105684383336754  0.0108158220024722 
                120                  78                 213                 206 
  0.010862365876275  0.0111783249552697  0.0114810562571757  0.0116639598405433 
                145                 444                 216                 365 
 0.0118375774260151  0.0118885448916409  0.0119585886330023  0.0120654984199943 
                120                 226                  97                  81 
 0.0121436389221869  0.0127263614373815  0.0128509045539613  0.0130247850278199 
                127                 276                 411                 225 
  0.013088276246171  0.0132057674167902  0.0133810487007935  0.0134591854570879 
                 23                 171                 255                 121 
 0.0135111727005023  0.0135225216646034  0.0139675349188373  0.0140120610145442 
                293                 298                 227                 469 
  0.014044436416185  0.0142175009388916  0.0143145007984184  0.0143663767587997 
                146                 262                 436                 317 
 0.0146315889810314  0.0147458840372226    0.01517663563321  0.0152375935889236 
                487                 127                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167711021009952    0.01692628480314  0.0172651069685975  0.0172672341551625 
                366                 262                 273                 316 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0175423941191212 
                230                 536                 463                 252 
 0.0176991150442478  0.0177547118273696  0.0178211163416274  0.0178593575592211 
                194                 164                 119                 227 
 0.0178794178794179  0.0180489901160292  0.0180560891279293  0.0180937818552497 
                253                 370                 195                 156 
 0.0181434599156118  0.0182452374563992  0.0182575272261371  0.0186451971127152 
                278                 211                  17                 587 
 0.0186999343401182  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                148                 242                 154                 206 
 0.0196571428571429  0.0197222222222222   0.019878902830464  0.0198854061341422 
                283                 296                 195                 159 
 0.0199234423280911  0.0199362041467305  0.0200785994998214  0.0201068974293713 
                511                 173                 248                 259 
 0.0205553552109629  0.0206237424547284   0.020628078817734  0.0207115701072462 
                344                 141                 328                 150 
 0.0207501167194065  0.0208122398470019  0.0208385638965604   0.020919175911252 
                263                 172                 180                 151 
 0.0209403397866456  0.0210041364278107  0.0211323866711337  0.0211568322981366 
                190                 339                 326                 394 
 0.0211693548387097  0.0211998923863331  0.0212652844231792  0.0214106769286397 
                  9                  56                 162                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                145                  83                 377                  20 
 0.0223612146352529  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                119                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230552952202437  0.0230622919638611 
                 90                 281                 356                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0245203969128997  0.0246305418719212 
                307                 139                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251256281407035  0.0251697962445066  0.0251836306400839 
                166                 129                 153                 144 
 0.0251931417728382  0.0253712871287129  0.0253881661770877   0.025439388079584 
                405                 297                 203                 323 
 0.0254668930390492  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                134                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0264531848242255  0.0264725347452019 
                306                 371                 166                 156 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0274626865671642  0.0275103163686382  0.0275999116802826  0.0277726199633943 
                113                 398                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617  0.0287486347324076   0.028899183763512 
                289                 290                 181                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295295295295295  0.0295730980205104  0.0298372513562387 
                 95                 122                 247                 176 
 0.0298965967272362  0.0299936183790683  0.0299939283545841  0.0300218340611354 
                390                 326                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609   0.030411877394636 
                375                 245                 169                 266 
 0.0307638727652658  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                 22                 114                 189                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0320326150262085 
                229                 230                 135                  56 
 0.0320470415288497  0.0320665083135392  0.0323421107482804  0.0325513638418647 
                 66                  58                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346032855644879  0.0346534653465347 
                180                 135                  25                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0363489499192246 
                 70                 223                 183                 123 
 0.0365088419851683  0.0365853658536585   0.036608183005613  0.0366379310344828 
                169                 179                 188                 119 
 0.0367789392179636  0.0367839431449881  0.0368731563421829  0.0369127516778524 
                148                 168                  34                  26 
 0.0369810052109598  0.0369817341324224  0.0370029389894126  0.0370756402620608 
                198                 313                 167                  97 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                114                  89                   9                 123 
 0.0383953168044077  0.0384615384615385  0.0385852090032154  0.0386931402066889 
                231                 348                 147                 178 
  0.038787023977433  0.0388998035363458  0.0389047933641635  0.0389174319349488 
                413                 201                 155                 158 
 0.0391606080634501  0.0392809587217044  0.0395238095238095  0.0401267159450898 
                237                 232                 147                 121 
 0.0402792897631292  0.0403430749682338  0.0408432147562582    0.04099560761347 
                213                 185                   9                 104 
 0.0411866985437948  0.0412392825206459  0.0412587412587413  0.0412642669007902 
                 56                 120                 276                 198 
 0.0412852723944195  0.0412961567445365  0.0413082980012114  0.0415162454873646 
                235                 298                 373                 368 
 0.0415865384615385  0.0416666666666667  0.0416754367501579    0.04203013481364 
                319                 153                 233                 384 
 0.0422836752899197  0.0423121387283237  0.0425136916364987  0.0425763261129115 
                292                 187                  95                 335 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434476279943636  0.0434699883302045  0.0435029049171036 
                209                 352                 515                 177 
 0.0435547734271887  0.0435933286727255  0.0436484634957917  0.0437311002558735 
                176                  83                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
 0.0443974630021142   0.044525215810995  0.0445749030296677  0.0448607345329061 
                125                 226                 328                 322 
 0.0449438202247191  0.0451125472198807  0.0452668098463572  0.0453118266330111 
                 27                 311                  54                 310 
 0.0453752181500873  0.0454081632653061  0.0454771657160357  0.0458015267175573 
                186                 158                 193                  53 
 0.0458288578589331  0.0461725394896719  0.0462850182704019  0.0463034418891804 
                427                 125                 102                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012  0.0470430107526882  0.0472636815920398  0.0473098330241187 
                226                  76                 155                 127 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494997367035282  0.0496535796766744  0.0502816607552681  0.0509113764927718 
                106                  37                 509                 224 
 0.0511221945137157  0.0512921525370312  0.0513173417223751  0.0513616687062777 
                141                 194                 410                 343 
 0.0516417910447761  0.0518164504653419  0.0519694944571114   0.052053981907163 
                154                 253                 147                 167 
 0.0522055664835289  0.0522119900389417  0.0522693757168606  0.0524006824274921 
                260                 394                 165                 285 
 0.0526157299679707  0.0526235972095845  0.0527306967984934   0.052766292577279 
                159                 204                  78                 135 
 0.0529287585522802  0.0529417416647984   0.053186119873817  0.0538116591928251 
                158                 305                 493                 131 
  0.053840499816244  0.0538555691554468  0.0541211987798358  0.0541623127830024 
                239                 163                 227                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0551415797317437 
                149                 181                 239                 141 
 0.0552183277853926  0.0555828824397442  0.0557219892150989  0.0568402950626782 
                375                 283                 129                 171 
 0.0569210866752911  0.0571776155717762  0.0572625698324022  0.0574494949494949 
                220                 143                 208                 157 
 0.0577124691399777  0.0579365729738589  0.0579766536964981  0.0580472177728254 
                443                 327                 225                 215 
  0.058057312988463  0.0590868397493286  0.0594161801501251  0.0594954783436459 
                454                 214                  74                 271 
 0.0601947477131897  0.0603881058119328  0.0604450348721355  0.0605700712589074 
                127                 145                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0718046912398277  0.0722415428390768  0.0729649936735555 
                125                 175                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761194029850746  0.0761834556584725  0.0763305322128851              0.0765 
                162                 238                 147                 206 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0795717592592593  0.0797656602073006  0.0799757649197213 
                292                 146                 245                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821148001605597  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 35                 205                  67                 171 
 0.0850873264666368  0.0850877192982456   0.085838779956427  0.0871771217712177 
                181                 166                 169                 137 
 0.0871937608509935  0.0879211175020542  0.0885896527285613  0.0895895895895896 
                330                 110                 168                 228 
 0.0897435897435897  0.0903323105725727  0.0906718851924331  0.0907393359397794 
                154                 195                 131                  78 
 0.0907575035731301  0.0909478746509463  0.0913471466923659  0.0919729186043997 
                236                 184                 224                 315 
 0.0920472328923033  0.0925431139179014  0.0926889714993804  0.0931930062807673 
                156                 452                 144                  55 
 0.0936348693532846   0.093978102189781  0.0941611024293223  0.0942935459755794 
                 98                 173                 197                  92 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0955528846153846 
                140                 163                 209                 167 
 0.0958322934863988  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                492                 172                  80                 149 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0986763911399244 
                195                 169                 295                 119 
 0.0990077653149267   0.100058147336405   0.101239669421488   0.101467214104577 
                185                 399                 143                 269 
  0.101767857896291   0.102649006622517    0.10270393092479   0.102815564694717 
                176                 184                 157                 134 
  0.103008945513689   0.103597052549932   0.105719237435009   0.105905511811024 
                167                 139                 119                 345 
   0.10730054175318   0.108005366726297   0.108166470357283   0.109404990403071 
                150                 171                 170                 265 
  0.110151036178433   0.114229765013055   0.114525835974502   0.114706592610481 
                190                  73                 198                 518 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.122544159230289   0.123858909955167 
                102                  73                  54                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.135149023638232   0.136729555838747   0.145816826598586   0.146203845806626 
                234                 383                 388                 188 
  0.154871196536584   0.155465949820789   0.163961038961039   0.164057181756297 
                210                 200                 210                 196 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488   0.203438395415473    0.20463712781353 
                262                 218                 341                 276 
  0.205955334987593   0.234804706537631    0.25564486542374   0.261106454316848 
                319                 229                 237                 234 
  0.279759519038076 
                219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
0.00421523730224813 0.00448895027624309 0.00459066564651875 0.00490244627116965 
                311                 366                 194                 359 
0.00498367417081973 0.00522193211488251 0.00578130161876445 0.00587199060481503 
                193                 258                 287                 131 
0.00594273365748244 0.00623755806237558  0.0065345080763583 0.00696748506967485 
                112                 367                 301                 206 
0.00704322607374672   0.007119524248262 0.00724125750618156 0.00773480662983425 
                113                 208                 211                 167 
 0.0077958894401134 0.00793650793650794 0.00824175824175824 0.00832376578645235 
                 49                  41                 275                 264 
0.00844155844155844 0.00845335003130871 0.00846023688663283 0.00847457627118644 
                 54                 311                 123                  64 
0.00874488832966342 0.00897654011461318 0.00921172575924771 0.00921675385217608 
                269                 242                 272                 401 
0.00923076923076923 0.00925272484905513 0.00947762838880317 0.00959473005871402 
                202                 312                  62                 179 
 0.0096013554854803 0.00965107646622123 0.00992145514675486  0.0100413467217956 
                307                 179                 167                 160 
 0.0103092783505155  0.0103676377051266  0.0104117368670137  0.0105202478743335 
                  2                 315                 439                 120 
 0.0105263157894737  0.0105684383336754  0.0108158220024722   0.010862365876275 
                 78                 213                 206                 145 
 0.0111783249552697  0.0114810562571757  0.0116639598405433  0.0118375774260151 
                444                 216                 365                 120 
 0.0118885448916409  0.0119585886330023  0.0120654984199943  0.0121436389221869 
                226                  97                  81                 127 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226    0.01517663563321  0.0152375935889236   0.015375854214123 
                127                 226                 174                  40 
 0.0154054184575264   0.015446694767143    0.01551306498995  0.0157491098329225 
                132                 264                 260                  33 
 0.0158163905185268  0.0159854503685268  0.0161589895988113  0.0162093171665603 
                390                  35                 325                 199 
 0.0162519045200609  0.0163213683449771  0.0163260512097721  0.0164196123147092 
                 23                 467                 261                 226 
 0.0164333536214242  0.0164978360593875  0.0165365653245686  0.0165680473372781 
                 56                 544                 338                 215 
  0.016656038770565  0.0166853053008276  0.0166950069562529  0.0167711021009952 
                207                 151                 283                 366 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0209403397866456 
                172                 180                 151                 190 
 0.0210041364278107  0.0211323866711337  0.0211568322981366  0.0211693548387097 
                339                 326                 394                   9 
 0.0211998923863331  0.0212652844231792  0.0214106769286397  0.0215326155794807 
                 56                 162                 230                 124 
 0.0215746707761278  0.0216911764705882  0.0217065004041104  0.0217617659308621 
                 28                   4                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230552952202437  0.0230622919638611  0.0231803430690774 
                281                 356                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234526191491455 
                244                 439                  76                 222 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                139                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251256281407035  0.0251697962445066  0.0251836306400839  0.0251931417728382 
                129                 153                 144                 405 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0254668930390492 
                297                 203                 323                 134 
 0.0254880694143167  0.0255052935514918  0.0256829707181417  0.0257529463116543 
                179                 264                 187                 181 
 0.0257910706545297  0.0259743135518158   0.026079869600652  0.0261760937213985 
                259                 176                 213                 306 
 0.0262657244913807  0.0264531848242255  0.0264725347452019  0.0265044174029005 
                371                 166                 156                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0274423215573179  0.0274626865671642 
                394                  86                 144                 113 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609   0.030411877394636  0.0307638727652658 
                245                 169                 266                  22 
 0.0308211473565804  0.0308783642812435  0.0312345066931086   0.031352533722202 
                114                 189                 168                 157 
  0.031377415351888  0.0314051164566628  0.0315893385982231  0.0316351953842119 
                254                 250                  97                 229 
 0.0316678395496129  0.0317272248551869  0.0320326150262085  0.0320470415288497 
                230                 135                  56                  66 
 0.0320665083135392  0.0323421107482804  0.0325513638418647  0.0325693606755127 
                 58                 421                 181                 166 
 0.0326602346996686  0.0326864147088866  0.0327533265097236  0.0331766657450926 
                339                  99                  13                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387  0.0340782122905028 
                353                 142                 122                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0345318618725525  0.0346032855644879  0.0346534653465347  0.0347459003084916 
                135                  25                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0363489499192246  0.0365088419851683 
                223                 183                 123                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0385852090032154  0.0386931402066889   0.038787023977433 
                348                 147                 178                 413 
 0.0388998035363458  0.0389047933641635  0.0389174319349488  0.0391606080634501 
                201                 155                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0408432147562582    0.04099560761347  0.0411866985437948 
                185                   9                 104                  56 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0413082980012114  0.0415162454873646  0.0415865384615385 
                298                 373                 368                 319 
 0.0416666666666667  0.0416754367501579    0.04203013481364  0.0422836752899197 
                153                 233                 384                 292 
 0.0423121387283237  0.0425136916364987  0.0425763261129115  0.0426995042379658 
                187                  95                 335                 197 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434476279943636  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                352                 515                 177                 176 
 0.0435933286727255  0.0436484634957917  0.0437311002558735  0.0438813349814586 
                 83                 227                 225                 239 
 0.0439361466262656  0.0441482715535194  0.0442073170731707  0.0443974630021142 
                181                 137                  90                 125 
  0.044525215810995  0.0445749030296677  0.0448607345329061  0.0449438202247191 
                226                 328                 322                  27 
 0.0451125472198807  0.0452668098463572  0.0453118266330111  0.0453752181500873 
                311                  54                 310                 186 
 0.0454081632653061  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                158                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
 0.0470430107526882  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                 76                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494997367035282 
                165                 223                  98                 106 
 0.0496535796766744  0.0502816607552681  0.0509113764927718  0.0511221945137157 
                 37                 509                 224                 141 
 0.0512921525370312  0.0513173417223751  0.0513616687062777  0.0516417910447761 
                194                 410                 343                 154 
 0.0518164504653419  0.0519694944571114   0.052053981907163  0.0522055664835289 
                253                 147                 167                 260 
 0.0522119900389417  0.0522693757168606  0.0524006824274921  0.0526157299679707 
                394                 165                 285                 159 
 0.0526235972095845  0.0527306967984934   0.052766292577279  0.0529287585522802 
                204                  78                 135                 158 
 0.0529417416647984   0.053186119873817  0.0538116591928251   0.053840499816244 
                305                 493                 131                 239 
 0.0538555691554468  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                163                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0552183277853926 
                181                 239                 141                 375 
 0.0555828824397442  0.0557219892150989  0.0568402950626782  0.0569210866752911 
                283                 129                 171                 220 
 0.0571776155717762  0.0572625698324022  0.0574494949494949  0.0577124691399777 
                143                 208                 157                 443 
 0.0579365729738589  0.0579766536964981  0.0580472177728254   0.058057312988463 
                327                 225                 215                 454 
 0.0590868397493286  0.0594161801501251  0.0594954783436459  0.0601947477131897 
                214                  74                 271                 127 
 0.0603881058119328  0.0604450348721355  0.0605700712589074  0.0605714285714286 
                145                 263                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0645476772616137 
                341                  88                 157                 248 
 0.0646551724137931  0.0649717514124294  0.0654566518632941  0.0659246575342466 
                223                 333                 179                 214 
  0.065989847715736  0.0662208091218068  0.0663316582914573   0.066402490801019 
                104                 154                  50                 108 
 0.0664614270191959  0.0668523676880223  0.0676933491284481   0.067850348763475 
                140                 200                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0686325439266616 
                189                 163                 282                 224 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0718046912398277  0.0722415428390768  0.0729649936735555  0.0731810490693739 
                175                 123                  72                 147 
 0.0734780628510703  0.0735163861824624  0.0739031028851388   0.074849349825563 
                227                 170                 356                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0761194029850746 
                176                  72                 180                 162 
 0.0761834556584725  0.0763305322128851              0.0765  0.0771307365985345 
                238                 147                 206                 144 
 0.0772969491128418   0.077457264957265  0.0775623268698061   0.077792732166891 
                275                 178                 214                 292 
 0.0795717592592593  0.0797656602073006  0.0799757649197213  0.0800351802990325 
                146                 245                 126                 151 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0821148001605597 
                174                 331                  81                  35 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0895895895895896  0.0897435897435897 
                110                 168                 228                 154 
 0.0903323105725727  0.0906718851924331  0.0907393359397794  0.0907575035731301 
                195                 131                  78                 236 
 0.0909478746509463  0.0913471466923659  0.0919729186043997  0.0920472328923033 
                184                 224                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0968399592252803 
                172                  80                 149                 195 
 0.0971563981042654  0.0984356197352587  0.0986763911399244  0.0990077653149267 
                169                 295                 119                 185 
  0.100058147336405   0.101239669421488   0.101467214104577   0.101767857896291 
                399                 143                 269                 176 
  0.102649006622517    0.10270393092479   0.102815564694717   0.103008945513689 
                184                 157                 134                 167 
  0.103597052549932   0.105719237435009   0.105905511811024    0.10730054175318 
                139                 119                 345                 150 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.114229765013055   0.114525835974502   0.114706592610481   0.116141117702154 
                 73                 198                 518                 230 
  0.117099936431463   0.119464797706276   0.120465801097577   0.121081745543946 
                174                 199                 328                 102 
             0.1225   0.122544159230289   0.123858909955167   0.125036689169357 
                 73                  54                 269                 261 
  0.125267338832875   0.126307739369838   0.131510445635971   0.135149023638232 
                175                 204                 296                 234 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.155465949820789   0.163961038961039   0.164057181756297   0.172022950473442 
                200                 210                 196                 232 
  0.181258488003622   0.182134570765661   0.184947958366693   0.185637891520244 
                190                 212                 211                 262 
  0.189697630293488   0.203438395415473    0.20463712781353   0.205955334987593 
                218                 341                 276                 319 
  0.234804706537631    0.25564486542374   0.261106454316848   0.279759519038076 
                229                 237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00824175824175824 0.00832376578645235 0.00844155844155844 0.00845335003130871 
                275                 264                  54                 311 
0.00846023688663283 0.00847457627118644 0.00874488832966342 0.00897654011461318 
                123                  64                 269                 242 
0.00921172575924771 0.00921675385217608 0.00923076923076923 0.00925272484905513 
                272                 401                 202                 312 
0.00947762838880317 0.00959473005871402  0.0096013554854803 0.00965107646622123 
                 62                 179                 307                 179 
0.00992145514675486  0.0100413467217956  0.0103092783505155  0.0103676377051266 
                167                 160                   2                 315 
 0.0104117368670137  0.0105202478743335  0.0105263157894737  0.0105684383336754 
                439                 120                  78                 213 
 0.0108158220024722   0.010862365876275  0.0111783249552697  0.0114810562571757 
                206                 145                 444                 216 
 0.0116639598405433  0.0118375774260151  0.0118885448916409  0.0119585886330023 
                365                 120                 226                  97 
 0.0120654984199943  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 81                 127                 276                 411 
 0.0130247850278199   0.013088276246171  0.0132057674167902  0.0133810487007935 
                225                  23                 171                 255 
 0.0134591854570879  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                121                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314  0.0147458840372226    0.01517663563321 
                317                 487                 127                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0159854503685268 
                260                  33                 390                  35 
 0.0161589895988113  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                325                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0165680473372781   0.016656038770565  0.0166853053008276 
                338                 215                 207                 151 
 0.0166950069562529  0.0167711021009952    0.01692628480314  0.0172651069685975 
                283                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176991150442478  0.0177547118273696  0.0178211163416274 
                252                 194                 164                 119 
 0.0178593575592211  0.0178794178794179  0.0180489901160292  0.0180560891279293 
                227                 253                 370                 195 
 0.0180937818552497  0.0181434599156118  0.0182452374563992  0.0182575272261371 
                156                 278                 211                  17 
 0.0186451971127152  0.0186999343401182  0.0188848920863309  0.0194376952447067 
                587                 148                 242                 154 
 0.0194924196145943  0.0196571428571429  0.0197222222222222   0.019878902830464 
                206                 283                 296                 195 
 0.0198854061341422  0.0199234423280911  0.0199362041467305  0.0200785994998214 
                159                 511                 173                 248 
 0.0201068974293713  0.0205553552109629  0.0206237424547284   0.020628078817734 
                259                 344                 141                 328 
 0.0207115701072462  0.0207501167194065  0.0208122398470019  0.0208385638965604 
                150                 263                 172                 180 
  0.020919175911252  0.0209403397866456  0.0210041364278107  0.0211323866711337 
                151                 190                 339                 326 
 0.0211568322981366  0.0211693548387097  0.0211998923863331  0.0212652844231792 
                394                   9                  56                 162 
 0.0214106769286397  0.0215326155794807  0.0215746707761278  0.0216911764705882 
                230                 124                  28                   4 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0220403022670025  0.0220897615708275 
                174                 145                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0245203969128997 
                 61                 307                 139                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251256281407035  0.0251697962445066 
                268                 166                 129                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254668930390492  0.0254880694143167  0.0255052935514918 
                323                 134                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0274626865671642  0.0275103163686382  0.0275999116802826 
                144                 113                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
  0.030411877394636  0.0307638727652658  0.0308211473565804  0.0308783642812435 
                266                  22                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0316678395496129  0.0317272248551869 
                 97                 229                 230                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0323421107482804 
                 56                  66                  58                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0326864147088866 
                181                 166                 339                  99 
 0.0327533265097236  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 13                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346032855644879 
                183                 180                 135                  25 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0363489499192246  0.0365088419851683  0.0365853658536585   0.036608183005613 
                123                 169                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0367839431449881  0.0368731563421829 
                119                 148                 168                  34 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0370756402620608  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                 97                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382165605095541 
                260                 114                  89                   9 
 0.0382320029839612  0.0383953168044077  0.0384615384615385  0.0385852090032154 
                123                 231                 348                 147 
 0.0386931402066889   0.038787023977433  0.0388998035363458  0.0389047933641635 
                178                 413                 201                 155 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0408432147562582 
                121                 213                 185                   9 
   0.04099560761347  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                104                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594161801501251 
                215                 454                 214                  74 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0895895895895896  0.0897435897435897  0.0903323105725727  0.0906718851924331 
                228                 154                 195                 131 
 0.0907393359397794  0.0907575035731301  0.0909478746509463  0.0913471466923659 
                 78                 236                 184                 224 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                149                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626   0.154871196536584   0.155465949820789   0.163961038961039 
                188                 210                 200                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00824175824175824 0.00832376578645235 0.00844155844155844 0.00845335003130871 
                275                 264                  54                 311 
0.00846023688663283 0.00847457627118644 0.00874488832966342 0.00897654011461318 
                123                  64                 269                 242 
0.00921172575924771 0.00921675385217608 0.00923076923076923 0.00925272484905513 
                272                 401                 202                 312 
0.00947762838880317 0.00959473005871402  0.0096013554854803 0.00965107646622123 
                 62                 179                 307                 179 
0.00992145514675486  0.0100413467217956  0.0103092783505155  0.0103676377051266 
                167                 160                   2                 315 
 0.0104117368670137  0.0105202478743335  0.0105263157894737  0.0105684383336754 
                439                 120                  78                 213 
 0.0108158220024722   0.010862365876275  0.0111783249552697  0.0114810562571757 
                206                 145                 444                 216 
 0.0116639598405433  0.0118375774260151  0.0118885448916409  0.0119585886330023 
                365                 120                 226                  97 
 0.0120654984199943  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 81                 127                 276                 411 
 0.0130247850278199   0.013088276246171  0.0132057674167902  0.0133810487007935 
                225                  23                 171                 255 
 0.0134591854570879  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                121                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314  0.0147458840372226    0.01517663563321 
                317                 487                 127                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0159854503685268 
                260                  33                 390                  35 
 0.0161589895988113  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                325                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0165680473372781   0.016656038770565  0.0166853053008276 
                338                 215                 207                 151 
 0.0166950069562529  0.0167711021009952    0.01692628480314  0.0172651069685975 
                283                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176991150442478  0.0177547118273696  0.0178211163416274 
                252                 194                 164                 119 
 0.0178593575592211  0.0178794178794179  0.0180489901160292  0.0180560891279293 
                227                 253                 370                 195 
 0.0180937818552497  0.0181434599156118  0.0182452374563992  0.0182575272261371 
                156                 278                 211                  17 
 0.0186451971127152  0.0186999343401182  0.0188848920863309  0.0194376952447067 
                587                 148                 242                 154 
 0.0194924196145943  0.0196571428571429  0.0197222222222222   0.019878902830464 
                206                 283                 296                 195 
 0.0198854061341422  0.0199234423280911  0.0199362041467305  0.0200785994998214 
                159                 511                 173                 248 
 0.0201068974293713  0.0205553552109629  0.0206237424547284   0.020628078817734 
                259                 344                 141                 328 
 0.0207115701072462  0.0207501167194065  0.0208122398470019  0.0208385638965604 
                150                 263                 172                 180 
  0.020919175911252  0.0209403397866456  0.0210041364278107  0.0211323866711337 
                151                 190                 339                 326 
 0.0211568322981366  0.0211693548387097  0.0211998923863331  0.0212652844231792 
                394                   9                  56                 162 
 0.0214106769286397  0.0215326155794807  0.0215746707761278  0.0216911764705882 
                230                 124                  28                   4 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0220403022670025  0.0220897615708275 
                174                 145                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0245203969128997 
                 61                 307                 139                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251256281407035  0.0251697962445066 
                268                 166                 129                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254668930390492  0.0254880694143167  0.0255052935514918 
                323                 134                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0274626865671642  0.0275103163686382  0.0275999116802826 
                144                 113                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
  0.030411877394636  0.0307638727652658  0.0308211473565804  0.0308783642812435 
                266                  22                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0316678395496129  0.0317272248551869 
                 97                 229                 230                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0323421107482804 
                 56                  66                  58                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0326864147088866 
                181                 166                 339                  99 
 0.0327533265097236  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 13                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346032855644879 
                183                 180                 135                  25 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0363489499192246  0.0365088419851683  0.0365853658536585   0.036608183005613 
                123                 169                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0367839431449881  0.0368731563421829 
                119                 148                 168                  34 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0370756402620608  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                 97                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382165605095541 
                260                 114                  89                   9 
 0.0382320029839612  0.0383953168044077  0.0384615384615385  0.0385852090032154 
                123                 231                 348                 147 
 0.0386931402066889   0.038787023977433  0.0388998035363458  0.0389047933641635 
                178                 413                 201                 155 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0408432147562582 
                121                 213                 185                   9 
   0.04099560761347  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                104                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594161801501251 
                215                 454                 214                  74 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0895895895895896  0.0897435897435897  0.0903323105725727  0.0906718851924331 
                228                 154                 195                 131 
 0.0907393359397794  0.0907575035731301  0.0909478746509463  0.0913471466923659 
                 78                 236                 184                 224 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                149                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626   0.154871196536584   0.155465949820789   0.163961038961039 
                188                 210                 200                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00824175824175824 0.00832376578645235 0.00844155844155844 0.00845335003130871 
                275                 264                  54                 311 
0.00846023688663283 0.00847457627118644 0.00874488832966342 0.00897654011461318 
                123                  64                 269                 242 
0.00921172575924771 0.00921675385217608 0.00923076923076923 0.00925272484905513 
                272                 401                 202                 312 
0.00947762838880317 0.00959473005871402  0.0096013554854803 0.00965107646622123 
                 62                 179                 307                 179 
0.00992145514675486  0.0100413467217956  0.0103092783505155  0.0103676377051266 
                167                 160                   2                 315 
 0.0104117368670137  0.0105202478743335  0.0105263157894737  0.0105684383336754 
                439                 120                  78                 213 
 0.0108158220024722   0.010862365876275  0.0111783249552697  0.0114810562571757 
                206                 145                 444                 216 
 0.0116639598405433  0.0118375774260151  0.0118885448916409  0.0119585886330023 
                365                 120                 226                  97 
 0.0120654984199943  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 81                 127                 276                 411 
 0.0130247850278199   0.013088276246171  0.0132057674167902  0.0133810487007935 
                225                  23                 171                 255 
 0.0134591854570879  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                121                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314  0.0147458840372226    0.01517663563321 
                317                 487                 127                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0159854503685268 
                260                  33                 390                  35 
 0.0161589895988113  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                325                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0165680473372781   0.016656038770565  0.0166853053008276 
                338                 215                 207                 151 
 0.0166950069562529  0.0167711021009952    0.01692628480314  0.0172651069685975 
                283                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176991150442478  0.0177547118273696  0.0178211163416274 
                252                 194                 164                 119 
 0.0178593575592211  0.0178794178794179  0.0180489901160292  0.0180560891279293 
                227                 253                 370                 195 
 0.0180937818552497  0.0181434599156118  0.0182452374563992  0.0182575272261371 
                156                 278                 211                  17 
 0.0186451971127152  0.0186999343401182  0.0188848920863309  0.0194376952447067 
                587                 148                 242                 154 
 0.0194924196145943  0.0196571428571429  0.0197222222222222   0.019878902830464 
                206                 283                 296                 195 
 0.0198854061341422  0.0199234423280911  0.0199362041467305  0.0200785994998214 
                159                 511                 173                 248 
 0.0201068974293713  0.0205553552109629  0.0206237424547284   0.020628078817734 
                259                 344                 141                 328 
 0.0207115701072462  0.0207501167194065  0.0208122398470019  0.0208385638965604 
                150                 263                 172                 180 
  0.020919175911252  0.0209403397866456  0.0210041364278107  0.0211323866711337 
                151                 190                 339                 326 
 0.0211568322981366  0.0211693548387097  0.0211998923863331  0.0212652844231792 
                394                   9                  56                 162 
 0.0214106769286397  0.0215326155794807  0.0215746707761278  0.0216911764705882 
                230                 124                  28                   4 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0220403022670025  0.0220897615708275 
                174                 145                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0245203969128997 
                 61                 307                 139                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251256281407035  0.0251697962445066 
                268                 166                 129                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254668930390492  0.0254880694143167  0.0255052935514918 
                323                 134                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0274626865671642  0.0275103163686382  0.0275999116802826 
                144                 113                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
  0.030411877394636  0.0307638727652658  0.0308211473565804  0.0308783642812435 
                266                  22                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0316678395496129  0.0317272248551869 
                 97                 229                 230                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0323421107482804 
                 56                  66                  58                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0326864147088866 
                181                 166                 339                  99 
 0.0327533265097236  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 13                 139                 353                 142 
 0.0339709257842387  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                122                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346032855644879 
                183                 180                 135                  25 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0363489499192246  0.0365088419851683  0.0365853658536585   0.036608183005613 
                123                 169                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0367839431449881  0.0368731563421829 
                119                 148                 168                  34 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0370756402620608  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                 97                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382165605095541 
                260                 114                  89                   9 
 0.0382320029839612  0.0383953168044077  0.0384615384615385  0.0385852090032154 
                123                 231                 348                 147 
 0.0386931402066889   0.038787023977433  0.0388998035363458  0.0389047933641635 
                178                 413                 201                 155 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0408432147562582 
                121                 213                 185                   9 
   0.04099560761347  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                104                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                384                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431638211196045  0.0432341381246491 
                335                 197                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454771657160357 
                310                 186                 158                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012  0.0470430107526882  0.0472636815920398 
                274                 226                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0502816607552681 
                 98                 106                  37                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538555691554468  0.0541211987798358 
                131                 239                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0571776155717762  0.0572625698324022 
                171                 220                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594161801501251 
                215                 454                 214                  74 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0636079249217935  0.0641271581255138 
                220                 111                 341                  88 
 0.0643896976483763  0.0645476772616137  0.0646551724137931  0.0649717514124294 
                157                 248                 223                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0718046912398277  0.0722415428390768 
                 76                 125                 175                 123 
 0.0729649936735555  0.0731810490693739  0.0734780628510703  0.0735163861824624 
                 72                 147                 227                 170 
 0.0739031028851388   0.074849349825563  0.0753043119455333  0.0755026672137874 
                356                 127                 176                  72 
  0.075534556908353  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                180                 162                 238                 147 
             0.0765  0.0771307365985345  0.0772969491128418   0.077457264957265 
                206                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0795717592592593  0.0797656602073006 
                214                 292                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0808438558669541   0.081692573402418 
                126                 151                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0850873264666368  0.0850877192982456   0.085838779956427 
                171                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0885896527285613 
                137                 330                 110                 168 
 0.0895895895895896  0.0897435897435897  0.0903323105725727  0.0906718851924331 
                228                 154                 195                 131 
 0.0907393359397794  0.0907575035731301  0.0909478746509463  0.0913471466923659 
                 78                 236                 184                 224 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                149                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626   0.154871196536584   0.155465949820789   0.163961038961039 
                188                 210                 200                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> ##########################
> #Portugal
> ##########################
> 
> #By country
> country="Portugal"

> cntry<-"PT"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00824175824175824 0.00832376578645235 0.00844155844155844 0.00845335003130871 
                275                 264                  54                 311 
0.00846023688663283 0.00847457627118644 0.00874488832966342 0.00897654011461318 
                123                  64                 269                 242 
0.00921172575924771 0.00921675385217608 0.00923076923076923 0.00925272484905513 
                272                 401                 202                 312 
0.00947762838880317 0.00959473005871402  0.0096013554854803 0.00965107646622123 
                 62                 179                 307                 179 
0.00992145514675486  0.0100413467217956  0.0103092783505155  0.0103676377051266 
                167                 160                   2                 315 
 0.0104117368670137  0.0105202478743335  0.0105263157894737  0.0105684383336754 
                439                 120                  78                 213 
 0.0108158220024722   0.010862365876275  0.0111783249552697  0.0114810562571757 
                206                 145                 444                 216 
 0.0116639598405433  0.0118375774260151  0.0118885448916409  0.0119585886330023 
                365                 120                 226                  97 
 0.0120654984199943  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 81                 127                 276                 411 
 0.0130247850278199   0.013088276246171  0.0132057674167902  0.0133810487007935 
                225                  23                 171                 255 
 0.0134591854570879  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                121                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314  0.0147458840372226    0.01517663563321 
                317                 487                 127                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0159854503685268 
                260                  33                 390                  35 
 0.0161589895988113  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                325                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0165680473372781   0.016656038770565  0.0166853053008276 
                338                 215                 207                 151 
 0.0166950069562529  0.0167711021009952    0.01692628480314  0.0172651069685975 
                283                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176991150442478  0.0177547118273696  0.0178211163416274 
                252                 194                 164                 119 
 0.0178593575592211  0.0178794178794179  0.0180489901160292  0.0180560891279293 
                227                 253                 370                 195 
 0.0180937818552497  0.0181434599156118  0.0182452374563992  0.0182575272261371 
                156                 278                 211                  17 
 0.0186451971127152  0.0186999343401182  0.0188848920863309  0.0194376952447067 
                587                 148                 242                 154 
 0.0194924196145943  0.0196571428571429  0.0197222222222222   0.019878902830464 
                206                 283                 296                 195 
 0.0198854061341422  0.0199234423280911  0.0199362041467305  0.0200785994998214 
                159                 511                 173                 248 
 0.0201068974293713  0.0205553552109629  0.0206237424547284   0.020628078817734 
                259                 344                 141                 328 
 0.0207115701072462  0.0207501167194065  0.0208122398470019  0.0208385638965604 
                150                 263                 172                 180 
  0.020919175911252  0.0209403397866456  0.0210041364278107  0.0211323866711337 
                151                 190                 339                 326 
 0.0211568322981366  0.0211693548387097  0.0211998923863331  0.0212652844231792 
                394                   9                  56                 162 
 0.0214106769286397  0.0215326155794807  0.0215746707761278  0.0216911764705882 
                230                 124                  28                   4 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0220403022670025  0.0220897615708275 
                174                 145                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0245203969128997 
                 61                 307                 139                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251256281407035  0.0251697962445066 
                268                 166                 129                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254668930390492  0.0254880694143167  0.0255052935514918 
                323                 134                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0274626865671642  0.0275103163686382  0.0275999116802826 
                144                 113                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
 0.0302711239799947   0.030411877394636  0.0307638727652658  0.0308211473565804 
                111                 266                  22                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                135                  56                  66                  58 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0326864147088866  0.0327533265097236  0.0331766657450926  0.0332120109190173 
                 99                  13                 139                 353 
 0.0333333333333333  0.0339709257842387   0.034034034034034  0.0340782122905028 
                142                 122                 163                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0345318618725525  0.0346032855644879  0.0346534653465347  0.0347459003084916 
                135                  25                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0363489499192246  0.0365088419851683 
                223                 183                 123                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0383953168044077 
                 89                   9                 123                 231 
 0.0384615384615385  0.0385852090032154  0.0386931402066889   0.038787023977433 
                348                 147                 178                 413 
 0.0388998035363458  0.0389047933641635  0.0389174319349488  0.0391606080634501 
                201                 155                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0408432147562582    0.04099560761347  0.0411866985437948 
                185                   9                 104                  56 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0413082980012114  0.0415162454873646  0.0415865384615385 
                298                 373                 368                 319 
 0.0416666666666667  0.0416754367501579    0.04203013481364  0.0421978021978022 
                153                 233                 384                 242 
 0.0422836752899197  0.0423121387283237  0.0425136916364987  0.0425763261129115 
                292                 187                  95                 335 
 0.0426995042379658  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                197                 221                 135                 312 
 0.0433574207893274  0.0434476279943636  0.0434699883302045  0.0435029049171036 
                209                 352                 515                 177 
 0.0435547734271887  0.0435933286727255  0.0436484634957917  0.0437311002558735 
                176                  83                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
 0.0443974630021142   0.044525215810995  0.0445749030296677  0.0448607345329061 
                125                 226                 328                 322 
 0.0449438202247191  0.0451125472198807  0.0452668098463572  0.0453118266330111 
                 27                 311                  54                 310 
 0.0453752181500873  0.0454081632653061  0.0454236366109071  0.0454771657160357 
                186                 158                 165                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012   0.047008547008547  0.0470430107526882 
                274                 226                 109                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0497194815244728  0.0502816607552681  0.0509113764927718  0.0511221945137157 
                135                 509                 224                 141 
 0.0512921525370312  0.0513173417223751  0.0513616687062777  0.0516417910447761 
                194                 410                 343                 154 
 0.0518164504653419  0.0519694944571114   0.052053981907163  0.0522055664835289 
                253                 147                 167                 260 
 0.0522119900389417  0.0522693757168606  0.0524006824274921  0.0526157299679707 
                394                 165                 285                 159 
 0.0526235972095845  0.0527306967984934   0.052766292577279  0.0529287585522802 
                204                  78                 135                 158 
 0.0529417416647984   0.053186119873817  0.0538116591928251   0.053840499816244 
                305                 493                 131                 239 
 0.0538535513119934  0.0538555691554468  0.0541211987798358  0.0541623127830024 
                278                 163                 227                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0551415797317437 
                149                 181                 239                 141 
 0.0552183277853926  0.0555828824397442  0.0557219892150989  0.0568402950626782 
                375                 283                 129                 171 
 0.0569210866752911  0.0571776155717762  0.0572625698324022  0.0574494949494949 
                220                 143                 208                 157 
 0.0577124691399777  0.0579365729738589  0.0579766536964981  0.0580472177728254 
                443                 327                 225                 215 
  0.058057312988463  0.0590868397493286  0.0594161801501251  0.0594954783436459 
                454                 214                  74                 271 
 0.0601947477131897  0.0603881058119328  0.0604450348721355  0.0605700712589074 
                127                 145                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0718046912398277  0.0722415428390768  0.0729649936735555 
                125                 175                 123                  72 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0739031028851388 
                147                 227                 170                 356 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0761194029850746  0.0761834556584725  0.0763305322128851              0.0765 
                162                 238                 147                 206 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0795717592592593  0.0797656602073006  0.0799757649197213 
                292                 146                 245                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821148001605597  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 35                 205                  67                 171 
 0.0850873264666368  0.0850877192982456   0.085838779956427  0.0871771217712177 
                181                 166                 169                 137 
 0.0871937608509935  0.0879211175020542  0.0885896527285613  0.0895895895895896 
                330                 110                 168                 228 
 0.0897435897435897  0.0903323105725727  0.0906718851924331  0.0907393359397794 
                154                 195                 131                  78 
 0.0907575035731301  0.0909478746509463  0.0913471466923659  0.0919729186043997 
                236                 184                 224                 315 
 0.0920472328923033  0.0925431139179014  0.0926889714993804  0.0931930062807673 
                156                 452                 144                  55 
 0.0936348693532846   0.093978102189781  0.0941611024293223  0.0942935459755794 
                 98                 173                 197                  92 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0955528846153846 
                140                 163                 209                 167 
 0.0958322934863988  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                492                 172                  80                 149 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0986763911399244 
                195                 169                 295                 119 
 0.0990077653149267   0.100058147336405   0.101239669421488   0.101467214104577 
                185                 399                 143                 269 
  0.101767857896291   0.102649006622517    0.10270393092479   0.102815564694717 
                176                 184                 157                 134 
  0.103008945513689   0.103597052549932   0.105719237435009   0.105905511811024 
                167                 139                 119                 345 
   0.10730054175318   0.108005366726297   0.108166470357283   0.109404990403071 
                150                 171                 170                 265 
  0.110151036178433   0.114229765013055   0.114525835974502   0.114706592610481 
                190                  73                 198                 518 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.122544159230289   0.123858909955167 
                102                  73                  54                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.135149023638232   0.136729555838747   0.145816826598586   0.146203845806626 
                234                 383                 388                 188 
  0.154871196536584   0.155465949820789   0.163961038961039   0.164057181756297 
                210                 200                 210                 196 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488   0.203438395415473    0.20463712781353 
                262                 218                 341                 276 
  0.205955334987593   0.234804706537631    0.25564486542374   0.261106454316848 
                319                 229                 237                 234 
  0.279759519038076 
                219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00824175824175824 0.00832376578645235 0.00844155844155844 0.00845335003130871 
                275                 264                  54                 311 
0.00846023688663283 0.00847457627118644 0.00874488832966342 0.00897654011461318 
                123                  64                 269                 242 
0.00921172575924771 0.00921675385217608 0.00923076923076923 0.00925272484905513 
                272                 401                 202                 312 
0.00947762838880317 0.00959473005871402  0.0096013554854803 0.00965107646622123 
                 62                 179                 307                 179 
0.00992145514675486  0.0100413467217956  0.0103092783505155  0.0103676377051266 
                167                 160                   2                 315 
 0.0104117368670137  0.0105202478743335  0.0105263157894737  0.0105684383336754 
                439                 120                  78                 213 
 0.0108158220024722   0.010862365876275  0.0111783249552697  0.0114810562571757 
                206                 145                 444                 216 
 0.0116639598405433  0.0118375774260151  0.0118885448916409  0.0119585886330023 
                365                 120                 226                  97 
 0.0120654984199943  0.0121436389221869  0.0127263614373815  0.0128509045539613 
                 81                 127                 276                 411 
 0.0130247850278199   0.013088276246171  0.0132057674167902  0.0133810487007935 
                225                  23                 171                 255 
 0.0134591854570879  0.0135111727005023  0.0135225216646034  0.0139675349188373 
                121                 293                 298                 227 
 0.0140120610145442   0.014044436416185  0.0142175009388916  0.0143145007984184 
                469                 146                 262                 436 
 0.0143663767587997  0.0146315889810314  0.0147458840372226    0.01517663563321 
                317                 487                 127                 226 
 0.0152375935889236   0.015375854214123  0.0154054184575264   0.015446694767143 
                174                  40                 132                 264 
   0.01551306498995  0.0157491098329225  0.0158163905185268  0.0159854503685268 
                260                  33                 390                  35 
 0.0161589895988113  0.0162093171665603  0.0162519045200609  0.0163213683449771 
                325                 199                  23                 467 
 0.0163260512097721  0.0164196123147092  0.0164333536214242  0.0164978360593875 
                261                 226                  56                 544 
 0.0165365653245686  0.0165680473372781   0.016656038770565  0.0166853053008276 
                338                 215                 207                 151 
 0.0166950069562529  0.0167711021009952    0.01692628480314  0.0172651069685975 
                283                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176991150442478  0.0177547118273696  0.0178211163416274 
                252                 194                 164                 119 
 0.0178593575592211  0.0178794178794179  0.0180489901160292  0.0180560891279293 
                227                 253                 370                 195 
 0.0180937818552497  0.0181434599156118  0.0182452374563992  0.0182575272261371 
                156                 278                 211                  17 
 0.0186451971127152  0.0186999343401182  0.0188848920863309  0.0194376952447067 
                587                 148                 242                 154 
 0.0194924196145943  0.0196571428571429  0.0197222222222222   0.019878902830464 
                206                 283                 296                 195 
 0.0198854061341422  0.0199234423280911  0.0199362041467305  0.0200785994998214 
                159                 511                 173                 248 
 0.0201068974293713  0.0205553552109629  0.0206237424547284   0.020628078817734 
                259                 344                 141                 328 
 0.0207115701072462  0.0207501167194065  0.0208122398470019  0.0208385638965604 
                150                 263                 172                 180 
  0.020919175911252  0.0209403397866456  0.0210041364278107  0.0211323866711337 
                151                 190                 339                 326 
 0.0211568322981366  0.0211693548387097  0.0211998923863331  0.0212652844231792 
                394                   9                  56                 162 
 0.0214106769286397  0.0215326155794807  0.0215746707761278  0.0216911764705882 
                230                 124                  28                   4 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0220403022670025  0.0220897615708275 
                174                 145                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0244668911335578 
                 61                 307                 139                 154 
 0.0244889267461669  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                150                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251256281407035  0.0251697962445066  0.0251836306400839  0.0251931417728382 
                129                 153                 144                 405 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0254668930390492 
                297                 203                 323                 134 
 0.0254880694143167  0.0255052935514918  0.0256829707181417  0.0257529463116543 
                179                 264                 187                 181 
 0.0257910706545297  0.0259743135518158   0.026079869600652  0.0261760937213985 
                259                 176                 213                 306 
 0.0262657244913807  0.0264531848242255  0.0264725347452019  0.0265044174029005 
                371                 166                 156                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0274423215573179  0.0274626865671642 
                394                  86                 144                 113 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609  0.0302711239799947   0.030411877394636 
                245                 169                 111                 266 
 0.0307638727652658  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                 22                 114                 189                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0320326150262085 
                229                 230                 135                  56 
 0.0320470415288497  0.0320665083135392  0.0323421107482804  0.0325513638418647 
                 66                  58                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
  0.034034034034034  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                163                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346032855644879 
                183                 180                 135                  25 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0363489499192246  0.0365088419851683  0.0365853658536585   0.036608183005613 
                123                 169                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0367839431449881  0.0368731563421829 
                119                 148                 168                  34 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0370756402620608  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                 97                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0381717729784028  0.0382165605095541 
                260                 114                  89                   9 
 0.0382320029839612  0.0383953168044077  0.0384615384615385  0.0385852090032154 
                123                 231                 348                 147 
 0.0386931402066889   0.038787023977433  0.0388998035363458  0.0389047933641635 
                178                 413                 201                 155 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0408432147562582 
                121                 213                 185                   9 
   0.04099560761347  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                104                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0421978021978022  0.0422836752899197  0.0423121387283237 
                384                 242                 292                 187 
 0.0425136916364987  0.0425763261129115  0.0426995042379658  0.0431328036322361 
                 95                 335                 197                 123 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434476279943636  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                352                 515                 177                 176 
 0.0435933286727255  0.0436484634957917  0.0437311002558735  0.0438813349814586 
                 83                 227                 225                 239 
 0.0439361466262656  0.0441482715535194  0.0442073170731707  0.0443974630021142 
                181                 137                  90                 125 
  0.044525215810995  0.0445749030296677  0.0448607345329061  0.0449438202247191 
                226                 328                 322                  27 
 0.0451125472198807  0.0452668098463572  0.0453118266330111  0.0453752181500873 
                311                  54                 310                 186 
 0.0454081632653061  0.0454236366109071  0.0454771657160357  0.0458015267175573 
                158                 165                 193                  53 
 0.0458288578589331  0.0461725394896719  0.0462850182704019  0.0463034418891804 
                427                 125                 102                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012   0.047008547008547  0.0470430107526882  0.0472636815920398 
                226                 109                  76                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494997367035282  0.0496535796766744  0.0497194815244728 
                 98                 106                  37                 135 
 0.0502816607552681  0.0509113764927718  0.0511221945137157  0.0512921525370312 
                509                 224                 141                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526157299679707  0.0526235972095845 
                165                 285                 159                 204 
 0.0527306967984934   0.052766292577279  0.0529287585522802  0.0529417416647984 
                 78                 135                 158                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538535513119934 
                493                 131                 239                 278 
 0.0538555691554468  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                163                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0552183277853926 
                181                 239                 141                 375 
 0.0555828824397442  0.0557219892150989  0.0568402950626782  0.0569210866752911 
                283                 129                 171                 220 
 0.0571776155717762  0.0572625698324022  0.0574494949494949  0.0577124691399777 
                143                 208                 157                 443 
 0.0579365729738589  0.0579766536964981  0.0580472177728254   0.058057312988463 
                327                 225                 215                 454 
 0.0590868397493286  0.0594161801501251  0.0594954783436459  0.0601947477131897 
                214                  74                 271                 127 
 0.0603881058119328  0.0604450348721355  0.0605700712589074  0.0605714285714286 
                145                 263                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0645252183713722 
                341                  88                 157                 264 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0715539091440827  0.0718046912398277  0.0718416370106761 
                125                 283                 175                 154 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388  0.0746185336806848   0.074849349825563 
                170                 356                 182                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0761194029850746 
                176                  72                 180                 162 
 0.0761834556584725  0.0763305322128851              0.0765  0.0771307365985345 
                238                 147                 206                 144 
 0.0772969491128418   0.077457264957265  0.0775623268698061   0.077792732166891 
                275                 178                 214                 292 
 0.0781227011917022  0.0795717592592593  0.0797656602073006  0.0799757649197213 
                243                 146                 245                 126 
 0.0800351802990325  0.0808438558669541   0.081692573402418  0.0819262038774234 
                151                 174                 331                  81 
 0.0821148001605597  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 35                 205                  67                 171 
 0.0850873264666368  0.0850877192982456   0.085838779956427  0.0871771217712177 
                181                 166                 169                 137 
 0.0871937608509935  0.0879211175020542  0.0885896527285613  0.0895895895895896 
                330                 110                 168                 228 
 0.0897435897435897  0.0903323105725727  0.0906718851924331  0.0907393359397794 
                154                 195                 131                  78 
 0.0907575035731301  0.0909478746509463  0.0913471466923659  0.0919729186043997 
                236                 184                 224                 315 
 0.0920472328923033  0.0925431139179014  0.0926889714993804  0.0931930062807673 
                156                 452                 144                  55 
 0.0936348693532846   0.093978102189781  0.0941611024293223  0.0942935459755794 
                 98                 173                 197                  92 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0955528846153846 
                140                 163                 209                 167 
 0.0958322934863988  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                492                 172                  80                 149 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0986763911399244 
                195                 169                 295                 119 
 0.0990077653149267   0.100058147336405   0.101239669421488   0.101467214104577 
                185                 399                 143                 269 
  0.101767857896291   0.102649006622517    0.10270393092479   0.102815564694717 
                176                 184                 157                 134 
  0.103008945513689   0.103597052549932   0.105719237435009   0.105905511811024 
                167                 139                 119                 345 
   0.10730054175318   0.108005366726297   0.108166470357283   0.109404990403071 
                150                 171                 170                 265 
  0.110151036178433   0.114229765013055   0.114525835974502   0.114706592610481 
                190                  73                 198                 518 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.122544159230289   0.123858909955167 
                102                  73                  54                 269 
  0.125036689169357   0.125267338832875   0.126307739369838   0.131510445635971 
                261                 175                 204                 296 
  0.135149023638232   0.136729555838747   0.145816826598586   0.146203845806626 
                234                 383                 388                 188 
  0.154871196536584   0.155465949820789   0.163961038961039   0.164057181756297 
                210                 200                 210                 196 
  0.172022950473442   0.181258488003622   0.182134570765661   0.184947958366693 
                232                 190                 212                 211 
  0.185637891520244   0.189697630293488   0.203438395415473    0.20463712781353 
                262                 218                 341                 276 
  0.205955334987593   0.234804706537631    0.25564486542374   0.261106454316848 
                319                 229                 237                 234 
  0.279759519038076 
                219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00824175824175824 0.00832376578645235 0.00844155844155844 0.00845335003130871 
                275                 264                  54                 311 
0.00846023688663283 0.00847457627118644 0.00874488832966342 0.00897654011461318 
                123                  64                 269                 242 
0.00921172575924771 0.00921675385217608 0.00923076923076923 0.00925272484905513 
                272                 401                 202                 312 
0.00947762838880317 0.00959473005871402  0.0096013554854803 0.00965107646622123 
                 62                 179                 307                 179 
0.00992145514675486  0.0100413467217956  0.0103092783505155  0.0103676377051266 
                167                 160                   2                 315 
 0.0104117368670137  0.0105202478743335  0.0105263157894737  0.0105684383336754 
                439                 120                  78                 213 
 0.0108158220024722   0.010862365876275  0.0111783249552697  0.0114810562571757 
                206                 145                 444                 216 
 0.0116639598405433  0.0118375774260151  0.0118885448916409  0.0119585886330023 
                365                 120                 226                  97 
 0.0120654984199943  0.0121436389221869  0.0125066056015501  0.0127263614373815 
                 81                 127                  85                 276 
 0.0128509045539613  0.0130247850278199   0.013088276246171  0.0132057674167902 
                411                 225                  23                 171 
 0.0133810487007935  0.0134591854570879  0.0135111727005023  0.0135225216646034 
                255                 121                 293                 298 
 0.0139675349188373  0.0140120610145442   0.014044436416185  0.0142175009388916 
                227                 469                 146                 262 
 0.0143145007984184  0.0143663767587997  0.0146315889810314  0.0147458840372226 
                436                 317                 487                 127 
   0.01517663563321  0.0152375935889236   0.015375854214123  0.0154054184575264 
                226                 174                  40                 132 
  0.015446694767143    0.01551306498995  0.0157491098329225  0.0158163905185268 
                264                 260                  33                 390 
 0.0159854503685268  0.0161589895988113  0.0162093171665603  0.0162519045200609 
                 35                 325                 199                  23 
 0.0163213683449771  0.0163260512097721  0.0164196123147092  0.0164333536214242 
                467                 261                 226                  56 
 0.0164978360593875  0.0165365653245686  0.0165680473372781   0.016656038770565 
                544                 338                 215                 207 
 0.0166853053008276  0.0166950069562529  0.0167711021009952    0.01692628480314 
                151                 283                 366                 262 
 0.0172651069685975  0.0172672341551625  0.0172739541160594  0.0174939864421605 
                273                 316                 230                 536 
 0.0174951994879454  0.0175423941191212  0.0176991150442478  0.0177547118273696 
                463                 252                 194                 164 
 0.0178211163416274  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                119                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0182452374563992 
                195                 156                 278                 211 
 0.0182575272261371  0.0186451971127152  0.0186999343401182  0.0188848920863309 
                 17                 587                 148                 242 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                328                 150                 263                 172 
 0.0208385638965604   0.020919175911252  0.0209403397866456  0.0210041364278107 
                180                 151                 190                 339 
 0.0211323866711337  0.0211568322981366  0.0211693548387097  0.0211998923863331 
                326                 394                   9                  56 
 0.0212652844231792  0.0214106769286397  0.0215326155794807  0.0215746707761278 
                162                 230                 124                  28 
 0.0216911764705882  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                  4                 450                 247                 273 
 0.0217859707924348  0.0217929668152551  0.0219236493825174  0.0219341974077767 
                291                 174                 145                  52 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230552952202437  0.0230622919638611  0.0231803430690774 
                281                 356                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234526191491455 
                244                 439                  76                 222 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0244668911335578  0.0244889267461669  0.0245203969128997 
                139                 154                 150                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251256281407035  0.0251697962445066 
                268                 166                 129                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254668930390492  0.0254880694143167  0.0255052935514918 
                323                 134                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0264531848242255 
                213                 306                 371                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0274626865671642  0.0275103163686382  0.0275999116802826 
                144                 113                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
 0.0302711239799947   0.030411877394636  0.0307638727652658  0.0308211473565804 
                111                 266                  22                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                135                  56                  66                  58 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0326864147088866  0.0327533265097236  0.0331766657450926  0.0332120109190173 
                 99                  13                 139                 353 
 0.0333333333333333  0.0339709257842387   0.034034034034034  0.0340782122905028 
                142                 122                 163                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0345318618725525  0.0346032855644879  0.0346534653465347  0.0347459003084916 
                135                  25                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0363489499192246  0.0365088419851683 
                223                 183                 123                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0379829731499673  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                129                  89                   9                 123 
 0.0383953168044077  0.0384615384615385  0.0385852090032154  0.0386931402066889 
                231                 348                 147                 178 
  0.038787023977433  0.0388998035363458  0.0389047933641635  0.0389174319349488 
                413                 201                 155                 158 
 0.0391606080634501  0.0392809587217044  0.0395238095238095  0.0401267159450898 
                237                 232                 147                 121 
 0.0402792897631292  0.0403430749682338  0.0408432147562582    0.04099560761347 
                213                 185                   9                 104 
 0.0411866985437948  0.0412392825206459  0.0412587412587413  0.0412642669007902 
                 56                 120                 276                 198 
 0.0412852723944195  0.0412961567445365  0.0413082980012114  0.0415162454873646 
                235                 298                 373                 368 
 0.0415865384615385  0.0416666666666667  0.0416754367501579    0.04203013481364 
                319                 153                 233                 384 
 0.0421978021978022  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                242                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431328036322361  0.0431638211196045 
                335                 197                 123                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434476279943636 
                135                 312                 209                 352 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0435933286727255 
                515                 177                 176                  83 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0448607345329061  0.0449438202247191  0.0451125472198807 
                328                 322                  27                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454236366109071  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                165                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
  0.047008547008547  0.0470430107526882  0.0472636815920398  0.0473098330241187 
                109                  76                 155                 127 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494997367035282  0.0496535796766744  0.0497194815244728  0.0502816607552681 
                106                  37                 135                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538535513119934  0.0538555691554468 
                131                 239                 278                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0569312169312169 
                129                 171                 220                 124 
 0.0571776155717762  0.0572625698324022  0.0574494949494949  0.0577124691399777 
                143                 208                 157                 443 
 0.0579365729738589  0.0579766536964981  0.0580472177728254   0.058057312988463 
                327                 225                 215                 454 
 0.0590868397493286  0.0594161801501251  0.0594954783436459  0.0601947477131897 
                214                  74                 271                 127 
 0.0603881058119328  0.0604450348721355  0.0605700712589074  0.0605714285714286 
                145                 263                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0645252183713722 
                341                  88                 157                 264 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0715539091440827  0.0718046912398277  0.0718416370106761 
                125                 283                 175                 154 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0739031028851388  0.0739470173432438  0.0746185336806848 
                170                 356                 206                 182 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0757384498863923  0.0761194029850746  0.0761834556584725  0.0763305322128851 
                329                 162                 238                 147 
             0.0765  0.0767867139391678  0.0771307365985345  0.0772969491128418 
                206                 404                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0781227011917022 
                178                 214                 292                 243 
 0.0795717592592593  0.0797656602073006  0.0799757649197213  0.0800351802990325 
                146                 245                 126                 151 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0821148001605597 
                174                 331                  81                  35 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0885896527285613  0.0895895895895896  0.0897435897435897 
                110                 168                 228                 154 
 0.0903323105725727  0.0906718851924331  0.0907393359397794  0.0907575035731301 
                195                 131                  78                 236 
 0.0909478746509463  0.0913471466923659  0.0918690601900739  0.0919729186043997 
                184                 224                 353                 315 
 0.0920472328923033  0.0925431139179014  0.0926889714993804  0.0931930062807673 
                156                 452                 144                  55 
 0.0936348693532846   0.093978102189781  0.0941611024293223  0.0942935459755794 
                 98                 173                 197                  92 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0955528846153846 
                140                 163                 209                 167 
 0.0958322934863988  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                492                 172                  80                 149 
 0.0964261631827377  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                181                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.114229765013055   0.114525835974502 
                265                 190                  73                 198 
  0.114706592610481   0.116141117702154   0.117099936431463   0.119464797706276 
                518                 230                 174                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.125036689169357   0.125267338832875   0.126307739369838 
                269                 261                 175                 204 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626   0.154871196536584   0.155465949820789   0.163961038961039 
                188                 210                 200                 210 
  0.164057181756297   0.172022950473442   0.181258488003622   0.182134570765661 
                196                 232                 190                 212 
  0.184947958366693   0.185637891520244   0.189697630293488   0.203438395415473 
                211                 262                 218                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226    0.01517663563321  0.0152375935889236   0.015375854214123 
                127                 226                 174                  40 
 0.0154054184575264   0.015446694767143    0.01551306498995  0.0157491098329225 
                132                 264                 260                  33 
 0.0158163905185268  0.0159854503685268  0.0161589895988113  0.0162093171665603 
                390                  35                 325                 199 
 0.0162519045200609  0.0163213683449771  0.0163260512097721  0.0164196123147092 
                 23                 467                 261                 226 
 0.0164333536214242  0.0164978360593875  0.0165365653245686  0.0165680473372781 
                 56                 544                 338                 215 
  0.016656038770565  0.0166853053008276  0.0166950069562529  0.0167711021009952 
                207                 151                 283                 366 
   0.01692628480314  0.0172651069685975  0.0172672341551625  0.0172739541160594 
                262                 273                 316                 230 
 0.0174939864421605  0.0174951994879454  0.0175423941191212  0.0176991150442478 
                536                 463                 252                 194 
 0.0177547118273696  0.0178211163416274  0.0178593575592211  0.0178794178794179 
                164                 119                 227                 253 
 0.0180489901160292  0.0180560891279293  0.0180937818552497  0.0181434599156118 
                370                 195                 156                 278 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                242                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                173                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0207115701072462  0.0207501167194065 
                141                 328                 150                 263 
 0.0208122398470019  0.0208385638965604   0.020919175911252  0.0209403397866456 
                172                 180                 151                 190 
 0.0210041364278107  0.0211323866711337  0.0211568322981366  0.0211693548387097 
                339                 326                 394                   9 
 0.0211998923863331  0.0212652844231792  0.0214106769286397  0.0215326155794807 
                 56                 162                 230                 124 
 0.0215746707761278  0.0216911764705882  0.0217065004041104  0.0217617659308621 
                 28                   4                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0219341974077767  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                 52                  83                 377                  20 
 0.0223612146352529  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                119                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230552952202437  0.0230622919638611 
                 90                 281                 356                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0242544731610338 
                227                 163                 123                  61 
 0.0243264977885002  0.0243547800799709  0.0244668911335578  0.0244889267461669 
                307                 139                 154                 150 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251256281407035 
                115                 268                 166                 129 
 0.0251697962445066  0.0251836306400839  0.0251931417728382  0.0253712871287129 
                153                 144                 405                 297 
 0.0253881661770877   0.025439388079584  0.0254668930390492  0.0254880694143167 
                203                 323                 134                 179 
 0.0255052935514918  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                264                 187                 181                 259 
 0.0259743135518158   0.026079869600652  0.0261760937213985  0.0262657244913807 
                176                 213                 306                 371 
 0.0264531848242255  0.0264725347452019  0.0265044174029005  0.0266179390521136 
                166                 156                 409                 231 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0270745772651745  0.0272490757223059 
                200                 243                 210                 394 
           0.027375  0.0274423215573179  0.0274626865671642  0.0274893097128894 
                 86                 144                 113                  54 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609  0.0302711239799947   0.030411877394636 
                245                 169                 111                 266 
 0.0307638727652658  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                 22                 114                 189                 168 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0320326150262085 
                229                 230                 135                  56 
 0.0320470415288497  0.0320665083135392  0.0323421107482804  0.0325513638418647 
                 66                  58                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
  0.034034034034034  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                163                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346032855644879 
                183                 180                 135                  25 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0363489499192246  0.0365088419851683  0.0365853658536585   0.036608183005613 
                123                 169                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0367839431449881  0.0368731563421829 
                119                 148                 168                  34 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0370756402620608  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                 97                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0379829731499673  0.0381717729784028 
                260                 114                 129                  89 
 0.0382165605095541  0.0382320029839612  0.0383953168044077  0.0384615384615385 
                  9                 123                 231                 348 
 0.0385852090032154  0.0386931402066889   0.038787023977433  0.0388998035363458 
                147                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0406144781144781  0.0408432147562582    0.04099560761347  0.0411866985437948 
                194                   9                 104                  56 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0413082980012114  0.0415162454873646  0.0415865384615385 
                298                 373                 368                 319 
 0.0416666666666667  0.0416754367501579    0.04203013481364  0.0421978021978022 
                153                 233                 384                 242 
 0.0422836752899197  0.0423121387283237  0.0425136916364987  0.0425763261129115 
                292                 187                  95                 335 
 0.0426995042379658  0.0431328036322361  0.0431638211196045  0.0432341381246491 
                197                 123                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454236366109071 
                310                 186                 158                 165 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012   0.047008547008547 
                221                 274                 226                 109 
 0.0470430107526882  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                 76                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494997367035282 
                165                 223                  98                 106 
 0.0496535796766744  0.0496568429551877  0.0497194815244728  0.0502816607552681 
                 37                 137                 135                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538535513119934  0.0538555691554468 
                131                 239                 278                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0569312169312169 
                129                 171                 220                 124 
 0.0571776155717762  0.0572625698324022  0.0574494949494949  0.0577124691399777 
                143                 208                 157                 443 
 0.0579365729738589  0.0579766536964981  0.0580472177728254   0.058057312988463 
                327                 225                 215                 454 
 0.0590868397493286  0.0594161801501251  0.0594954783436459  0.0601947477131897 
                214                  74                 271                 127 
 0.0603881058119328  0.0604450348721355  0.0605700712589074  0.0605714285714286 
                145                 263                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0645252183713722 
                341                  88                 157                 264 
 0.0645476772616137  0.0646551724137931  0.0649717514124294  0.0654566518632941 
                248                 223                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0715539091440827  0.0718046912398277  0.0718416370106761 
                125                 283                 175                 154 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0737867751395327  0.0739031028851388  0.0739470173432438 
                170                 332                 356                 206 
 0.0746185336806848   0.074849349825563  0.0753043119455333  0.0755026672137874 
                182                 127                 176                  72 
  0.075534556908353  0.0757384498863923  0.0761194029850746  0.0761608704099475 
                180                 329                 162                 206 
 0.0761834556584725  0.0763305322128851              0.0765  0.0767867139391678 
                238                 147                 206                 404 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0781227011917022  0.0795717592592593  0.0797656602073006 
                292                 243                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0803679496489954  0.0806698903172544 
                126                 151                 203                 390 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0821148001605597 
                174                 331                  81                  35 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0883005267535348  0.0885896527285613  0.0895895895895896 
                110                 310                 168                 228 
 0.0897435897435897  0.0903323105725727  0.0906718851924331  0.0907393359397794 
                154                 195                 131                  78 
 0.0907575035731301  0.0909478746509463  0.0913471466923659  0.0918690601900739 
                236                 184                 224                 353 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0964261631827377  0.0968399592252803  0.0971563981042654 
                149                 181                 195                 169 
 0.0984356197352587  0.0986763911399244  0.0990077653149267   0.100058147336405 
                295                 119                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024    0.10730054175318   0.108005366726297 
                119                 345                 150                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.114229765013055 
                170                 265                 190                  73 
  0.114525835974502   0.114706592610481   0.116141117702154   0.117099936431463 
                198                 518                 230                 174 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.122544159230289   0.123858909955167   0.125036689169357   0.125267338832875 
                 54                 269                 261                 175 
  0.126307739369838   0.131510445635971   0.135149023638232   0.136729555838747 
                204                 296                 234                 383 
  0.145816826598586   0.146203845806626   0.154871196536584   0.155465949820789 
                388                 188                 210                 200 
  0.163961038961039   0.164057181756297   0.172022950473442   0.181258488003622 
                210                 196                 232                 190 
  0.182134570765661   0.184947958366693   0.185637891520244   0.189697630293488 
                212                 211                 262                 218 
  0.203438395415473    0.20463712781353   0.205955334987593   0.234804706537631 
                341                 276                 319                 229 
   0.25564486542374   0.261106454316848   0.279759519038076 
                237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167711021009952    0.01692628480314  0.0172651069685975  0.0172672341551625 
                366                 262                 273                 316 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0175423941191212 
                230                 536                 463                 252 
 0.0176991150442478  0.0177547118273696  0.0178211163416274  0.0178593575592211 
                194                 164                 119                 227 
 0.0178794178794179  0.0180489901160292  0.0180560891279293  0.0180937818552497 
                253                 370                 195                 156 
 0.0181434599156118  0.0182452374563992  0.0182575272261371  0.0186451971127152 
                278                 211                  17                 587 
 0.0186999343401182  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                148                 242                 154                 206 
 0.0196571428571429  0.0197222222222222   0.019878902830464  0.0198854061341422 
                283                 296                 195                 159 
 0.0199234423280911  0.0199362041467305  0.0200785994998214  0.0201068974293713 
                511                 173                 248                 259 
 0.0205553552109629  0.0206237424547284   0.020628078817734  0.0207115701072462 
                344                 141                 328                 150 
 0.0207501167194065  0.0208122398470019  0.0208385638965604   0.020919175911252 
                263                 172                 180                 151 
 0.0209403397866456  0.0210041364278107  0.0211323866711337  0.0211568322981366 
                190                 339                 326                 394 
 0.0211693548387097  0.0211998923863331  0.0212652844231792  0.0214106769286397 
                  9                  56                 162                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0219341974077767  0.0220403022670025  0.0220897615708275 
                145                  52                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0244668911335578 
                 61                 307                 139                 154 
 0.0244889267461669  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                150                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251256281407035  0.0251697962445066  0.0251836306400839  0.0251931417728382 
                129                 153                 144                 405 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0254668930390492 
                297                 203                 323                 134 
 0.0254880694143167  0.0255052935514918  0.0256829707181417  0.0257529463116543 
                179                 264                 187                 181 
 0.0257910706545297  0.0259743135518158   0.026079869600652  0.0261760937213985 
                259                 176                 213                 306 
 0.0262657244913807  0.0264531848242255  0.0264725347452019  0.0265044174029005 
                371                 166                 156                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0274423215573179  0.0274626865671642 
                394                  86                 144                 113 
 0.0274893097128894  0.0275103163686382  0.0275999116802826  0.0277726199633943 
                 54                 398                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617  0.0287486347324076   0.028899183763512 
                289                 290                 181                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295295295295295  0.0295730980205104  0.0298372513562387 
                 95                 122                 247                 176 
 0.0298965967272362  0.0299936183790683  0.0299939283545841  0.0300218340611354 
                390                 326                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609  0.0302711239799947 
                375                 245                 169                 111 
  0.030411877394636  0.0307638727652658  0.0308211473565804  0.0308783642812435 
                266                  22                 114                 189 
 0.0312345066931086   0.031352533722202   0.031377415351888  0.0314051164566628 
                168                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0316678395496129  0.0317272248551869 
                 97                 229                 230                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0322131636508252 
                 56                  66                  58                 150 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0326864147088866  0.0327533265097236  0.0331766657450926  0.0332120109190173 
                 99                  13                 139                 353 
 0.0333333333333333  0.0339709257842387   0.034034034034034  0.0340782122905028 
                142                 122                 163                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0345318618725525  0.0346032855644879  0.0346534653465347  0.0347459003084916 
                135                  25                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629  0.0359856057576969   0.036105476673428  0.0361134995700774 
                 76                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0363489499192246  0.0365088419851683 
                223                 183                 123                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0379829731499673  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                129                  89                   9                 123 
 0.0382728164867517  0.0383953168044077  0.0384615384615385  0.0385852090032154 
                 39                 231                 348                 147 
 0.0386931402066889   0.038787023977433  0.0388998035363458  0.0389047933641635 
                178                 413                 201                 155 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0406144781144781 
                121                 213                 185                 194 
 0.0408432147562582    0.04099560761347  0.0411866985437948  0.0412392825206459 
                  9                 104                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415162454873646  0.0415865384615385  0.0416666666666667 
                373                 368                 319                 153 
 0.0416754367501579    0.04203013481364  0.0421978021978022  0.0422836752899197 
                233                 384                 242                 292 
 0.0423121387283237  0.0425136916364987  0.0425763261129115  0.0426995042379658 
                187                  95                 335                 197 
 0.0431328036322361  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                123                 221                 135                 312 
 0.0433574207893274  0.0434476279943636  0.0434699883302045  0.0435029049171036 
                209                 352                 515                 177 
 0.0435547734271887  0.0435933286727255  0.0436484634957917  0.0437311002558735 
                176                  83                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
 0.0443974630021142   0.044525215810995  0.0445749030296677  0.0448607345329061 
                125                 226                 328                 322 
 0.0449438202247191  0.0451125472198807  0.0452668098463572  0.0453118266330111 
                 27                 311                  54                 310 
 0.0453752181500873  0.0454081632653061  0.0454236366109071  0.0454771657160357 
                186                 158                 165                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012   0.047008547008547  0.0470430107526882 
                274                 226                 109                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0496568429551877  0.0497194815244728  0.0502816607552681  0.0509113764927718 
                137                 135                 509                 224 
 0.0511221945137157  0.0512921525370312  0.0513173417223751  0.0513616687062777 
                141                 194                 410                 343 
 0.0516417910447761  0.0518164504653419  0.0519694944571114   0.052053981907163 
                154                 253                 147                 167 
 0.0522055664835289  0.0522119900389417  0.0522693757168606  0.0524006824274921 
                260                 394                 165                 285 
 0.0526157299679707  0.0526235972095845  0.0527306967984934   0.052766292577279 
                159                 204                  78                 135 
 0.0529287585522802  0.0529417416647984   0.053186119873817  0.0538116591928251 
                158                 305                 493                 131 
  0.053840499816244  0.0538535513119934  0.0538555691554468  0.0541211987798358 
                239                 278                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0569312169312169  0.0571776155717762 
                171                 220                 124                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0579766536964981  0.0580472177728254   0.058057312988463  0.0590868397493286 
                225                 215                 454                 214 
 0.0594161801501251  0.0594954783436459  0.0601947477131897  0.0603881058119328 
                 74                 271                 127                 145 
 0.0604450348721355  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                263                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0636079249217935 
                210                 220                 111                 341 
 0.0641271581255138  0.0643896976483763  0.0645252183713722  0.0645476772616137 
                 88                 157                 264                 248 
 0.0646551724137931  0.0646766169154229  0.0649717514124294  0.0654566518632941 
                223                 116                 333                 179 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676933491284481 
                108                 140                 200                 256 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0683411214953271 
                 74                 189                 163                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0704392560348239  0.0705556460811471 
                287                 243                 135                  76 
 0.0710715061943056  0.0715539091440827  0.0718046912398277  0.0718416370106761 
                125                 283                 175                 154 
 0.0722415428390768  0.0729649936735555  0.0731810490693739  0.0734780628510703 
                123                  72                 147                 227 
 0.0735163861824624  0.0737867751395327  0.0739031028851388  0.0739470173432438 
                170                 332                 356                 206 
 0.0746185336806848   0.074849349825563  0.0753043119455333  0.0755026672137874 
                182                 127                 176                  72 
  0.075534556908353  0.0757384498863923  0.0761194029850746  0.0761608704099475 
                180                 329                 162                 206 
 0.0761834556584725  0.0763305322128851              0.0765  0.0767867139391678 
                238                 147                 206                 404 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077792732166891  0.0781227011917022  0.0795717592592593  0.0797656602073006 
                292                 243                 146                 245 
 0.0799757649197213  0.0800351802990325  0.0803679496489954  0.0806698903172544 
                126                 151                 203                 390 
 0.0808438558669541   0.081692573402418  0.0819262038774234  0.0821148001605597 
                174                 331                  81                  35 
 0.0821542674577818  0.0829190693974945  0.0845114315664221  0.0850873264666368 
                205                  67                 171                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0879211175020542  0.0883005267535348  0.0885896527285613  0.0895895895895896 
                110                 310                 168                 228 
 0.0897435897435897  0.0903323105725727  0.0906718851924331  0.0907393359397794 
                154                 195                 131                  78 
 0.0907575035731301  0.0909478746509463  0.0913471466923659  0.0918690601900739 
                236                 184                 224                 353 
 0.0919729186043997  0.0920472328923033  0.0925431139179014  0.0926889714993804 
                315                 156                 452                 144 
 0.0931930062807673  0.0936348693532846   0.093978102189781  0.0941611024293223 
                 55                  98                 173                 197 
 0.0942935459755794  0.0944649446494465  0.0946155169447789  0.0951444859445646 
                 92                 140                 163                 209 
 0.0955528846153846  0.0958322934863988  0.0958677685950413  0.0961078221438468 
                167                 492                 172                  80 
 0.0964175143741707  0.0964261631827377  0.0968399592252803  0.0971563981042654 
                149                 181                 195                 169 
 0.0984356197352587  0.0986763911399244  0.0990077653149267   0.100058147336405 
                295                 119                 185                 399 
  0.101239669421488   0.101467214104577   0.101767857896291   0.102649006622517 
                143                 269                 176                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024    0.10730054175318   0.108005366726297 
                119                 345                 150                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.112025605852766 
                170                 265                 190                 202 
  0.112173739788803   0.114229765013055   0.114525835974502   0.114706592610481 
                178                  73                 198                 518 
  0.116141117702154   0.117099936431463   0.119464797706276   0.120465801097577 
                230                 174                 199                 328 
  0.121081745543946              0.1225   0.122544159230289   0.123858909955167 
                102                  73                  54                 269 
  0.124222197081118   0.125036689169357   0.125267338832875    0.12553251917069 
                406                 261                 175                 319 
  0.126307739369838   0.126770467101959   0.131510445635971   0.135149023638232 
                204                 378                 296                 234 
  0.136729555838747   0.145816826598586   0.146203845806626   0.154871196536584 
                383                 388                 188                 210 
  0.155465949820789   0.163961038961039   0.164057181756297   0.172022950473442 
                200                 210                 196                 232 
  0.181258488003622   0.182134570765661   0.184947958366693   0.185637891520244 
                190                 212                 211                 262 
  0.189697630293488   0.203438395415473    0.20463712781353   0.205955334987593 
                218                 341                 276                 319 
  0.234804706537631    0.25564486542374   0.261106454316848   0.279759519038076 
                229                 237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167711021009952    0.01692628480314  0.0172651069685975  0.0172672341551625 
                366                 262                 273                 316 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0175423941191212 
                230                 536                 463                 252 
 0.0176991150442478  0.0177547118273696  0.0178211163416274  0.0178593575592211 
                194                 164                 119                 227 
 0.0178794178794179  0.0180489901160292  0.0180560891279293  0.0180937818552497 
                253                 370                 195                 156 
 0.0181434599156118  0.0182452374563992  0.0182575272261371  0.0186451971127152 
                278                 211                  17                 587 
 0.0186999343401182  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                148                 242                 154                 206 
 0.0196571428571429  0.0197222222222222   0.019878902830464  0.0198854061341422 
                283                 296                 195                 159 
 0.0199234423280911  0.0199362041467305  0.0200785994998214  0.0201068974293713 
                511                 173                 248                 259 
 0.0205553552109629  0.0206237424547284   0.020628078817734  0.0207115701072462 
                344                 141                 328                 150 
 0.0207501167194065  0.0208122398470019  0.0208385638965604   0.020919175911252 
                263                 172                 180                 151 
 0.0209403397866456  0.0210041364278107  0.0211323866711337  0.0211568322981366 
                190                 339                 326                 394 
 0.0211693548387097  0.0211998923863331  0.0212652844231792  0.0214106769286397 
                  9                  56                 162                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0219341974077767  0.0220403022670025  0.0220897615708275 
                145                  52                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0244668911335578 
                 61                 307                 139                 154 
 0.0244889267461669  0.0245016611295681  0.0245203969128997  0.0246305418719212 
                150                 121                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251256281407035  0.0251697962445066  0.0251836306400839 
                166                 129                 153                 144 
 0.0251931417728382  0.0253712871287129  0.0253881661770877   0.025439388079584 
                405                 297                 203                 323 
 0.0254668930390492  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                134                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0264531848242255  0.0264725347452019 
                306                 371                 166                 156 
 0.0265044174029005  0.0266179390521136  0.0266429840142096  0.0266724967205947 
                409                 231                 191                 198 
 0.0267139027192646  0.0269498482955559  0.0269736842105263  0.0270528760759667 
                260                 175                 200                 243 
 0.0270745772651745  0.0272490757223059            0.027375  0.0274423215573179 
                210                 394                  86                 144 
 0.0274626865671642  0.0274893097128894  0.0275103163686382  0.0275999116802826 
                113                  54                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
 0.0302711239799947   0.030411877394636  0.0307638727652658  0.0308211473565804 
                111                 266                  22                 114 
 0.0308783642812435  0.0312345066931086   0.031352533722202   0.031377415351888 
                189                 168                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0320326150262085  0.0320470415288497  0.0320665083135392 
                135                  56                  66                  58 
 0.0322131636508252  0.0323421107482804  0.0325513638418647  0.0325693606755127 
                150                 421                 181                 166 
 0.0326602346996686  0.0326864147088866  0.0327533265097236  0.0331766657450926 
                339                  99                  13                 139 
 0.0332120109190173  0.0333333333333333  0.0339709257842387   0.034034034034034 
                353                 142                 122                 163 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346032855644879  0.0346534653465347 
                180                 135                  25                  25 
 0.0347459003084916  0.0348244147157191  0.0348890414092885  0.0349115972430327 
                203                 152                 205                 291 
 0.0350253807106599  0.0350921393607832  0.0351497282512167  0.0351973182995581 
                 53                 160                 406                 349 
 0.0353383458646617  0.0353873479983604    0.03547209181012  0.0354838709677419 
                267                  69                  45                 176 
 0.0356401384083045  0.0356612184249629  0.0359856057576969   0.036105476673428 
                132                  76                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0363489499192246 
                 70                 223                 183                 123 
 0.0365088419851683  0.0365853658536585   0.036608183005613  0.0366379310344828 
                169                 179                 188                 119 
 0.0367789392179636  0.0367839431449881  0.0368731563421829  0.0369127516778524 
                148                 168                  34                  26 
 0.0369810052109598  0.0369817341324224  0.0370029389894126  0.0370756402620608 
                198                 313                 167                  97 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0379829731499673  0.0381717729784028  0.0382165605095541 
                114                 129                  89                   9 
 0.0382320029839612  0.0382728164867517  0.0383953168044077  0.0384615384615385 
                123                  39                 231                 348 
 0.0385852090032154  0.0386931402066889   0.038787023977433  0.0388998035363458 
                147                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0406144781144781  0.0408432147562582    0.04099560761347  0.0411866985437948 
                194                   9                 104                  56 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0413082980012114  0.0415162454873646  0.0415865384615385 
                298                 373                 368                 319 
 0.0416666666666667  0.0416754367501579    0.04203013481364  0.0421978021978022 
                153                 233                 384                 242 
 0.0422836752899197  0.0423121387283237  0.0425136916364987  0.0425763261129115 
                292                 187                  95                 335 
 0.0426995042379658  0.0431328036322361  0.0431638211196045  0.0432341381246491 
                197                 123                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454236366109071 
                310                 186                 158                 165 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012   0.047008547008547 
                221                 274                 226                 109 
 0.0470430107526882  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                 76                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494997367035282 
                165                 223                  98                 106 
 0.0496535796766744  0.0496568429551877  0.0497194815244728  0.0502816607552681 
                 37                 137                 135                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538535513119934  0.0538555691554468 
                131                 239                 278                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0569312169312169 
                129                 171                 220                 124 
 0.0571776155717762  0.0572625698324022  0.0574494949494949  0.0577124691399777 
                143                 208                 157                 443 
 0.0579365729738589  0.0579766536964981  0.0580472177728254   0.058057312988463 
                327                 225                 215                 454 
 0.0590868397493286  0.0594161801501251  0.0594954783436459  0.0601947477131897 
                214                  74                 271                 127 
 0.0603881058119328  0.0604450348721355  0.0605700712589074  0.0605714285714286 
                145                 263                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0645252183713722 
                341                  88                 157                 264 
 0.0645476772616137  0.0646551724137931  0.0646766169154229  0.0649717514124294 
                248                 223                 116                 333 
 0.0654566518632941  0.0659246575342466   0.065989847715736  0.0662208091218068 
                179                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676933491284481   0.067850348763475   0.068041136618414  0.0681222707423581 
                256                  74                 189                 163 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0715539091440827  0.0718046912398277 
                 76                 125                 283                 175 
 0.0718416370106761  0.0722415428390768  0.0729649936735555  0.0731810490693739 
                154                 123                  72                 147 
 0.0734780628510703  0.0735163861824624  0.0737867751395327  0.0739031028851388 
                227                 170                 332                 356 
 0.0739470173432438  0.0746185336806848   0.074849349825563  0.0753043119455333 
                206                 182                 127                 176 
 0.0755026672137874   0.075534556908353  0.0757384498863923  0.0757575757575758 
                 72                 180                 329                  32 
 0.0761194029850746  0.0761608704099475  0.0761834556584725  0.0763305322128851 
                162                 206                 238                 147 
             0.0765  0.0767867139391678  0.0771307365985345  0.0772969491128418 
                206                 404                 144                 275 
  0.077457264957265  0.0775623268698061   0.077792732166891  0.0781227011917022 
                178                 214                 292                 243 
 0.0795717592592593  0.0797656602073006  0.0799757649197213  0.0800351802990325 
                146                 245                 126                 151 
 0.0803679496489954  0.0806698903172544  0.0808438558669541   0.081692573402418 
                203                 390                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0845241304933944  0.0850873264666368  0.0850877192982456 
                171                 154                 181                 166 
  0.085838779956427  0.0871771217712177  0.0871937608509935  0.0879211175020542 
                169                 137                 330                 110 
 0.0883005267535348  0.0885896527285613  0.0895895895895896  0.0897435897435897 
                310                 168                 228                 154 
 0.0903323105725727  0.0906718851924331  0.0907393359397794  0.0907575035731301 
                195                 131                  78                 236 
 0.0909478746509463  0.0913471466923659  0.0918690601900739  0.0919729186043997 
                184                 224                 353                 315 
 0.0920472328923033  0.0925431139179014  0.0926889714993804  0.0931930062807673 
                156                 452                 144                  55 
 0.0936348693532846   0.093978102189781  0.0941611024293223  0.0942935459755794 
                 98                 173                 197                  92 
 0.0944649446494465  0.0946155169447789  0.0951444859445646  0.0955528846153846 
                140                 163                 209                 167 
 0.0958322934863988  0.0958677685950413  0.0961078221438468  0.0964175143741707 
                492                 172                  80                 149 
 0.0964261631827377  0.0968399592252803  0.0971563981042654  0.0984356197352587 
                181                 195                 169                 295 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.112025605852766   0.112173739788803 
                265                 190                 202                 178 
  0.114229765013055   0.114525835974502   0.114706592610481   0.116141117702154 
                 73                 198                 518                 230 
  0.117099936431463   0.118951612903226   0.119464797706276   0.120465801097577 
                174                 142                 199                 328 
  0.121081745543946              0.1225   0.122544159230289   0.123858909955167 
                102                  73                  54                 269 
  0.124222197081118   0.125036689169357   0.125267338832875    0.12553251917069 
                406                 261                 175                 319 
  0.126307739369838   0.126770467101959   0.131510445635971   0.135149023638232 
                204                 378                 296                 234 
  0.136729555838747   0.145816826598586   0.146203845806626     0.1463243873979 
                383                 388                 188                 247 
  0.153031761308951   0.154871196536584   0.155465949820789   0.162202043132804 
                173                 210                 200                 454 
  0.163961038961039   0.164057181756297   0.172022950473442   0.181258488003622 
                210                 196                 232                 190 
  0.182134570765661   0.182632457871565   0.184947958366693   0.185637891520244 
                212                 294                 211                 262 
  0.189697630293488   0.198355345128333   0.203438395415473    0.20463712781353 
                218                 243                 341                 276 
  0.205955334987593   0.234804706537631    0.25564486542374   0.261106454316848 
                319                 229                 237                 234 
  0.279759519038076 
                219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167711021009952    0.01692628480314  0.0172651069685975  0.0172672341551625 
                366                 262                 273                 316 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0175423941191212 
                230                 536                 463                 252 
 0.0176991150442478  0.0177547118273696  0.0178211163416274  0.0178593575592211 
                194                 164                 119                 227 
 0.0178794178794179  0.0180489901160292  0.0180560891279293  0.0180937818552497 
                253                 370                 195                 156 
 0.0181434599156118  0.0182452374563992  0.0182575272261371  0.0186451971127152 
                278                 211                  17                 587 
 0.0186999343401182  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                148                 242                 154                 206 
 0.0196571428571429  0.0197222222222222   0.019878902830464  0.0198854061341422 
                283                 296                 195                 159 
 0.0199234423280911  0.0199362041467305  0.0200785994998214  0.0201068974293713 
                511                 173                 248                 259 
 0.0205553552109629  0.0206237424547284   0.020628078817734  0.0207115701072462 
                344                 141                 328                 150 
 0.0207501167194065  0.0208122398470019  0.0208385638965604   0.020919175911252 
                263                 172                 180                 151 
 0.0209403397866456  0.0210041364278107  0.0211323866711337  0.0211568322981366 
                190                 339                 326                 394 
 0.0211693548387097  0.0211998923863331  0.0212652844231792  0.0214106769286397 
                  9                  56                 162                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0219341974077767  0.0220403022670025  0.0220897615708275 
                145                  52                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0244668911335578 
                 61                 307                 139                 154 
 0.0244889267461669  0.0245016611295681  0.0245203969128997  0.0246305418719212 
                150                 121                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251256281407035  0.0251697962445066  0.0251836306400839 
                166                 129                 153                 144 
 0.0251931417728382  0.0253712871287129  0.0253881661770877   0.025439388079584 
                405                 297                 203                 323 
 0.0254668930390492  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                134                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0263574064312072  0.0264531848242255 
                306                 371                  46                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0274626865671642  0.0274893097128894  0.0275103163686382 
                144                 113                  54                 398 
 0.0275999116802826  0.0277726199633943  0.0279437271150511   0.027964785085448 
                320                 316                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
 0.0287486347324076   0.028899183763512  0.0290282520956225  0.0291580880307162 
                181                 135                  61                 120 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295295295295295 
                174                 331                  95                 122 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609  0.0302711239799947   0.030411877394636  0.0307638727652658 
                169                 111                 266                  22 
 0.0308211473565804  0.0308783642812435  0.0312345066931086   0.031352533722202 
                114                 189                 168                 157 
  0.031377415351888  0.0314051164566628  0.0315893385982231  0.0316351953842119 
                254                 250                  97                 229 
 0.0316678395496129  0.0317272248551869  0.0320326150262085  0.0320470415288497 
                230                 135                  56                  66 
 0.0320665083135392  0.0322131636508252  0.0323421107482804  0.0325513638418647 
                 58                 150                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
  0.034034034034034  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                163                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346032855644879 
                183                 180                 135                  25 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0363489499192246  0.0365088419851683  0.0365853658536585   0.036608183005613 
                123                 169                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0367839431449881  0.0368731563421829 
                119                 148                 168                  34 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0370756402620608  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                 97                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0379829731499673  0.0381717729784028 
                260                 114                 129                  89 
 0.0382165605095541  0.0382320029839612  0.0382728164867517  0.0383953168044077 
                  9                 123                  39                 231 
 0.0384615384615385  0.0385852090032154  0.0386931402066889   0.038787023977433 
                348                 147                 178                 413 
 0.0388998035363458  0.0389047933641635  0.0389174319349488  0.0391606080634501 
                201                 155                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0406144781144781  0.0408432147562582    0.04099560761347 
                185                 194                   9                 104 
 0.0411866985437948  0.0412392825206459  0.0412587412587413  0.0412642669007902 
                 56                 120                 276                 198 
 0.0412852723944195  0.0412961567445365  0.0413082980012114  0.0415162454873646 
                235                 298                 373                 368 
 0.0415865384615385  0.0416666666666667  0.0416754367501579    0.04203013481364 
                319                 153                 233                 384 
 0.0421978021978022  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                242                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431328036322361  0.0431638211196045 
                335                 197                 123                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434476279943636 
                135                 312                 209                 352 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0435933286727255 
                515                 177                 176                  83 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0448607345329061  0.0449438202247191  0.0451125472198807 
                328                 322                  27                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454236366109071  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                165                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
  0.047008547008547  0.0470430107526882  0.0472636815920398  0.0473098330241187 
                109                  76                 155                 127 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494997367035282  0.0496535796766744  0.0496568429551877  0.0497194815244728 
                106                  37                 137                 135 
 0.0502816607552681  0.0509113764927718  0.0511221945137157  0.0512921525370312 
                509                 224                 141                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526157299679707  0.0526235972095845 
                165                 285                 159                 204 
 0.0527306967984934   0.052766292577279  0.0529287585522802  0.0529417416647984 
                 78                 135                 158                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538535513119934 
                493                 131                 239                 278 
 0.0538555691554468  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                163                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0552183277853926 
                181                 239                 141                 375 
 0.0555828824397442  0.0557219892150989  0.0568402950626782  0.0569210866752911 
                283                 129                 171                 220 
 0.0569312169312169  0.0571776155717762  0.0572625698324022  0.0574494949494949 
                124                 143                 208                 157 
 0.0577124691399777  0.0579365729738589  0.0579766536964981  0.0580472177728254 
                443                 327                 225                 215 
  0.058057312988463  0.0590868397493286  0.0594161801501251  0.0594954783436459 
                454                 214                  74                 271 
 0.0601947477131897  0.0603881058119328  0.0604450348721355  0.0605700712589074 
                127                 145                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645252183713722  0.0645476772616137  0.0646551724137931  0.0646766169154229 
                264                 248                 223                 116 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676125848241826  0.0676933491284481   0.067850348763475 
                200                 155                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0686325439266616 
                189                 163                 282                 224 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0715539091440827  0.0718046912398277  0.0718416370106761  0.0722415428390768 
                283                 175                 154                 123 
 0.0729649936735555  0.0730528709494031  0.0731810490693739  0.0734780628510703 
                 72                  30                 147                 227 
 0.0735163861824624  0.0737867751395327  0.0739031028851388  0.0739470173432438 
                170                 332                 356                 206 
 0.0746185336806848   0.074849349825563  0.0753043119455333  0.0755026672137874 
                182                 127                 176                  72 
  0.075534556908353  0.0757384498863923  0.0757575757575758  0.0761194029850746 
                180                 329                  32                 162 
 0.0761608704099475  0.0761834556584725  0.0763305322128851              0.0765 
                206                 238                 147                 206 
 0.0767867139391678  0.0771307365985345  0.0772969491128418   0.077457264957265 
                404                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0781227011917022  0.0795717592592593 
                214                 292                 243                 146 
 0.0797656602073006  0.0799757649197213  0.0800351802990325  0.0803679496489954 
                245                 126                 151                 203 
 0.0806698903172544  0.0808438558669541   0.081692573402418  0.0819262038774234 
                390                 174                 331                  81 
 0.0821148001605597  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 35                 205                  67                 171 
 0.0845241304933944  0.0850873264666368  0.0850877192982456   0.085838779956427 
                154                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0883005267535348 
                137                 330                 110                 310 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0918690601900739  0.0919729186043997  0.0920472328923033 
                224                 353                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0964261631827377 
                172                  80                 149                 181 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0984398216939079 
                195                 169                 295                  80 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.112025605852766   0.112173739788803 
                265                 190                 202                 178 
  0.114229765013055   0.114525835974502   0.114706592610481   0.115978211529732 
                 73                 198                 518                 102 
  0.116141117702154   0.117099936431463   0.118951612903226   0.119464797706276 
                230                 174                 142                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.124222197081118   0.125036689169357   0.125267338832875 
                269                 406                 261                 175 
   0.12553251917069   0.126307739369838   0.126770467101959   0.131510445635971 
                319                 204                 378                 296 
  0.135149023638232   0.136729555838747   0.145816826598586   0.146203845806626 
                234                 383                 388                 188 
    0.1463243873979   0.148916657113378   0.152476213710661   0.153031761308951 
                247                 211                 112                 173 
  0.154871196536584   0.155465949820789    0.16151983045716   0.162202043132804 
                210                 200                 186                 454 
  0.163961038961039   0.164057181756297   0.167901234567901   0.172022950473442 
                210                 196                 167                 232 
  0.181258488003622   0.182134570765661   0.182632457871565   0.184947958366693 
                190                 212                 294                 211 
  0.185637891520244   0.189697630293488   0.198355345128333   0.203438395415473 
                262                 218                 243                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> 
> #Occupation Risk
> table(Empl$GEO)

                                         Austria 
                                            2880 
                                         Belgium 
                                            2880 
                                        Bulgaria 
                                            2880 
                                         Croatia 
                                            2880 
                                          Cyprus 
                                            2880 
                                  Czech Republic 
                                            2880 
                                         Denmark 
                                            2880 
                                         Estonia 
                                            2880 
                        Euro area (17 countries) 
                                            2880 
                        Euro area (18 countries) 
                                            2880 
                        Euro area (19 countries) 
                                            2880 
                   European Union (15 countries) 
                                            2880 
                   European Union (27 countries) 
                                            2880 
                   European Union (28 countries) 
                                            2880 
                                         Finland 
                                            2880 
      Former Yugoslav Republic of Macedonia, the 
                                            2880 
                                          France 
                                            2880 
Germany (until 1990 former territory of the FRG) 
                                            2880 
                                          Greece 
                                            2880 
                                         Hungary 
                                            2880 
                                         Iceland 
                                            2880 
                                         Ireland 
                                            2880 
                                           Italy 
                                            2880 
                                          Latvia 
                                            2880 
                                       Lithuania 
                                            2880 
                                      Luxembourg 
                                            2880 
                                           Malta 
                                            2880 
                                     Netherlands 
                                            2880 
                                          Norway 
                                            2880 
                                          Poland 
                                            2880 
                                        Portugal 
                                            2880 
                                         Romania 
                                            2880 
                                        Slovakia 
                                            2880 
                                        Slovenia 
                                            2880 
                                           Spain 
                                            2880 
                                          Sweden 
                                            2880 
                                     Switzerland 
                                            2880 
                                          Turkey 
                                            2880 
                                  United Kingdom 
                                            2880 

> #Austria,Belgium,Denmark,Finland,France,
> #Germany (until 1990 former territory of the FRG),Ireland,
> #Italy,Netherlands,Norway,Portugal,Spain,Sweden,Switzerland,United Kingdom
> 
> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> #AT BE CH DE DK ES FI FR GB IE IT NL NO PT SE
> 
> 
> 
> ##########################
> #Sweden
> ##########################
> 
> country="Sweden"

> cntry<-"SE"

> year=2002

> round<-1

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167711021009952    0.01692628480314  0.0172651069685975  0.0172672341551625 
                366                 262                 273                 316 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0175423941191212 
                230                 536                 463                 252 
 0.0176991150442478  0.0177547118273696  0.0178211163416274  0.0178593575592211 
                194                 164                 119                 227 
 0.0178794178794179  0.0180489901160292  0.0180560891279293  0.0180937818552497 
                253                 370                 195                 156 
 0.0181434599156118  0.0182452374563992  0.0182575272261371  0.0186451971127152 
                278                 211                  17                 587 
 0.0186999343401182  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                148                 242                 154                 206 
 0.0196571428571429  0.0197222222222222   0.019878902830464  0.0198854061341422 
                283                 296                 195                 159 
 0.0199234423280911  0.0199362041467305  0.0200785994998214  0.0201068974293713 
                511                 173                 248                 259 
 0.0205553552109629  0.0206237424547284   0.020628078817734  0.0207115701072462 
                344                 141                 328                 150 
 0.0207501167194065  0.0208122398470019  0.0208385638965604   0.020919175911252 
                263                 172                 180                 151 
 0.0209403397866456  0.0210041364278107  0.0211323866711337  0.0211568322981366 
                190                 339                 326                 394 
 0.0211693548387097  0.0211998923863331  0.0212652844231792  0.0214106769286397 
                  9                  56                 162                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0219341974077767  0.0220403022670025  0.0220897615708275 
                145                  52                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0244668911335578 
                 61                 307                 139                 154 
 0.0244889267461669  0.0245016611295681  0.0245203969128997  0.0246305418719212 
                150                 121                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251256281407035  0.0251697962445066  0.0251836306400839 
                166                 129                 153                 144 
 0.0251931417728382  0.0253712871287129  0.0253881661770877   0.025439388079584 
                405                 297                 203                 323 
 0.0254668930390492  0.0254880694143167  0.0255052935514918  0.0256829707181417 
                134                 179                 264                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0263574064312072  0.0264531848242255 
                306                 371                  46                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0274423215573179  0.0274626865671642  0.0274893097128894  0.0275103163686382 
                144                 113                  54                 398 
 0.0275999116802826  0.0277726199633943  0.0279437271150511   0.027964785085448 
                320                 316                 234                  65 
 0.0282313475062647   0.028270509977827  0.0285470085470085  0.0286692340607617 
                337                  65                 289                 290 
 0.0287486347324076   0.028899183763512  0.0290282520956225  0.0291580880307162 
                181                 135                  61                 120 
 0.0292200966996006  0.0292865871644684   0.029377657518361  0.0295295295295295 
                174                 331                  95                 122 
 0.0295730980205104  0.0298372513562387  0.0298965967272362  0.0299936183790683 
                247                 176                 390                 326 
 0.0299939283545841  0.0300218340611354  0.0300982800982801   0.030188679245283 
                228                 366                 375                 245 
 0.0301942222947609  0.0302711239799947   0.030411877394636  0.0307638727652658 
                169                 111                 266                  22 
 0.0308211473565804  0.0308783642812435  0.0312345066931086   0.031352533722202 
                114                 189                 168                 157 
  0.031377415351888  0.0314051164566628  0.0315893385982231  0.0316351953842119 
                254                 250                  97                 229 
 0.0316678395496129  0.0317272248551869  0.0320326150262085  0.0320470415288497 
                230                 135                  56                  66 
 0.0320665083135392  0.0322131636508252  0.0323421107482804  0.0325513638418647 
                 58                 150                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
  0.034034034034034  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                163                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346032855644879 
                183                 180                 135                  25 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629  0.0359856057576969 
                176                 132                  76                 242 
  0.036105476673428  0.0361134995700774  0.0362391785786189  0.0362541993281075 
                363                  70                 223                 183 
 0.0363489499192246  0.0365088419851683  0.0365853658536585   0.036608183005613 
                123                 169                 179                 188 
 0.0366379310344828  0.0367789392179636  0.0367839431449881  0.0368731563421829 
                119                 148                 168                  34 
 0.0369127516778524  0.0369810052109598  0.0369817341324224  0.0370029389894126 
                 26                 198                 313                 167 
 0.0370756402620608  0.0371853546910755  0.0373638098364692  0.0373705538045925 
                 97                 133                 334                  13 
 0.0375362566114997  0.0378919022889017  0.0379829731499673  0.0381717729784028 
                260                 114                 129                  89 
 0.0382165605095541  0.0382320029839612  0.0382728164867517  0.0383953168044077 
                  9                 123                  39                 231 
 0.0384615384615385  0.0385852090032154  0.0386931402066889   0.038787023977433 
                348                 147                 178                 413 
 0.0388998035363458  0.0389047933641635  0.0389174319349488  0.0391606080634501 
                201                 155                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0406144781144781  0.0408432147562582    0.04099560761347 
                185                 194                   9                 104 
 0.0411866985437948  0.0412392825206459  0.0412587412587413  0.0412642669007902 
                 56                 120                 276                 198 
 0.0412852723944195  0.0412961567445365  0.0413082980012114  0.0415162454873646 
                235                 298                 373                 368 
 0.0415865384615385  0.0416666666666667  0.0416754367501579    0.04203013481364 
                319                 153                 233                 384 
 0.0421978021978022  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                242                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431328036322361  0.0431638211196045 
                335                 197                 123                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434476279943636 
                135                 312                 209                 352 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0435933286727255 
                515                 177                 176                  83 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0448607345329061  0.0449438202247191  0.0451125472198807 
                328                 322                  27                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454236366109071  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                165                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
  0.047008547008547  0.0470430107526882  0.0472636815920398  0.0473098330241187 
                109                  76                 155                 127 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494997367035282  0.0496535796766744  0.0496568429551877  0.0497194815244728 
                106                  37                 137                 135 
 0.0502816607552681  0.0509113764927718  0.0511221945137157  0.0512921525370312 
                509                 224                 141                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526157299679707  0.0526235972095845 
                165                 285                 159                 204 
 0.0527306967984934   0.052766292577279  0.0529287585522802  0.0529417416647984 
                 78                 135                 158                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538535513119934 
                493                 131                 239                 278 
 0.0538555691554468  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                163                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0552183277853926 
                181                 239                 141                 375 
 0.0555828824397442  0.0557219892150989  0.0568402950626782  0.0569210866752911 
                283                 129                 171                 220 
 0.0569312169312169  0.0571776155717762  0.0572625698324022  0.0574494949494949 
                124                 143                 208                 157 
 0.0577124691399777  0.0579365729738589  0.0579766536964981  0.0580472177728254 
                443                 327                 225                 215 
  0.058057312988463  0.0590868397493286  0.0594161801501251  0.0594954783436459 
                454                 214                  74                 271 
 0.0601947477131897  0.0603881058119328  0.0604450348721355  0.0605700712589074 
                127                 145                 263                  27 
 0.0605714285714286  0.0605864166749776  0.0606246548444499  0.0610859728506787 
                150                 216                 210                 220 
  0.061569416498994  0.0636079249217935  0.0641271581255138  0.0643896976483763 
                111                 341                  88                 157 
 0.0645252183713722  0.0645476772616137  0.0646551724137931  0.0646766169154229 
                264                 248                 223                 116 
 0.0649717514124294  0.0654566518632941  0.0659246575342466   0.065989847715736 
                333                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676125848241826  0.0676933491284481   0.067850348763475 
                200                 155                 256                  74 
  0.068041136618414  0.0681222707423581  0.0683411214953271  0.0686325439266616 
                189                 163                 282                 224 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0715539091440827  0.0718046912398277  0.0718416370106761  0.0722415428390768 
                283                 175                 154                 123 
 0.0729649936735555  0.0730528709494031  0.0731810490693739  0.0734780628510703 
                 72                  30                 147                 227 
 0.0735163861824624  0.0737867751395327  0.0739031028851388  0.0739470173432438 
                170                 332                 356                 206 
 0.0746185336806848   0.074849349825563  0.0753043119455333  0.0755026672137874 
                182                 127                 176                  72 
  0.075534556908353  0.0757384498863923  0.0757575757575758  0.0761194029850746 
                180                 329                  32                 162 
 0.0761608704099475  0.0761834556584725  0.0763305322128851              0.0765 
                206                 238                 147                 206 
 0.0767867139391678  0.0771307365985345  0.0772969491128418   0.077457264957265 
                404                 144                 275                 178 
 0.0775623268698061   0.077792732166891  0.0781227011917022  0.0795717592592593 
                214                 292                 243                 146 
 0.0797656602073006  0.0799757649197213  0.0800351802990325  0.0803679496489954 
                245                 126                 151                 203 
 0.0806698903172544  0.0808438558669541   0.081692573402418  0.0819262038774234 
                390                 174                 331                  81 
 0.0821148001605597  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 35                 205                  67                 171 
 0.0845241304933944  0.0850873264666368  0.0850877192982456   0.085838779956427 
                154                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0883005267535348 
                137                 330                 110                 310 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0918690601900739  0.0919729186043997  0.0920472328923033 
                224                 353                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0964261631827377 
                172                  80                 149                 181 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0984398216939079 
                195                 169                 295                  80 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.112025605852766   0.112173739788803 
                265                 190                 202                 178 
  0.114229765013055   0.114525835974502   0.114706592610481   0.115978211529732 
                 73                 198                 518                 102 
  0.116141117702154   0.117099936431463   0.118951612903226   0.119464797706276 
                230                 174                 142                 199 
  0.120465801097577   0.121081745543946              0.1225   0.122544159230289 
                328                 102                  73                  54 
  0.123858909955167   0.124222197081118   0.125036689169357   0.125267338832875 
                269                 406                 261                 175 
   0.12553251917069   0.126307739369838   0.126770467101959   0.131510445635971 
                319                 204                 378                 296 
  0.135149023638232   0.136729555838747   0.145816826598586   0.146203845806626 
                234                 383                 388                 188 
    0.1463243873979   0.148916657113378   0.152476213710661   0.153031761308951 
                247                 211                 112                 173 
  0.154871196536584   0.155465949820789    0.16151983045716   0.162202043132804 
                210                 200                 186                 454 
  0.163961038961039   0.164057181756297   0.167901234567901   0.172022950473442 
                210                 196                 167                 232 
  0.181258488003622   0.182134570765661   0.182632457871565   0.184947958366693 
                190                 212                 294                 211 
  0.185637891520244   0.189697630293488   0.198355345128333   0.203438395415473 
                262                 218                 243                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2004

> round<-2

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167711021009952    0.01692628480314  0.0172651069685975  0.0172672341551625 
                366                 262                 273                 316 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0175423941191212 
                230                 536                 463                 252 
 0.0176991150442478  0.0177547118273696  0.0178211163416274  0.0178593575592211 
                194                 164                 119                 227 
 0.0178794178794179  0.0180489901160292  0.0180560891279293  0.0180937818552497 
                253                 370                 195                 156 
 0.0181434599156118  0.0182452374563992  0.0182575272261371  0.0186451971127152 
                278                 211                  17                 587 
 0.0186999343401182  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                148                 242                 154                 206 
 0.0196571428571429  0.0197222222222222   0.019878902830464  0.0198854061341422 
                283                 296                 195                 159 
 0.0199234423280911  0.0199362041467305  0.0200785994998214  0.0201068974293713 
                511                 173                 248                 259 
 0.0205553552109629  0.0206237424547284   0.020628078817734  0.0206629358588033 
                344                 141                 328                  88 
 0.0207115701072462  0.0207501167194065  0.0208122398470019  0.0208385638965604 
                150                 263                 172                 180 
  0.020919175911252  0.0209403397866456  0.0210041364278107  0.0211323866711337 
                151                 190                 339                 326 
 0.0211568322981366  0.0211693548387097  0.0211998923863331  0.0212652844231792 
                394                   9                  56                 162 
 0.0214106769286397  0.0215326155794807  0.0215746707761278  0.0216911764705882 
                230                 124                  28                   4 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0219341974077767  0.0220403022670025 
                174                 145                  52                  83 
 0.0220897615708275  0.0222703371481596  0.0223612146352529  0.0224536670362744 
                377                  20                 119                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230552952202437  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                356                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0244668911335578  0.0244889267461669  0.0245016611295681  0.0245203969128997 
                154                 150                 121                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251256281407035  0.0251697962445066 
                268                 166                 129                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254668930390492  0.0254880694143167  0.0255052935514918 
                323                 134                 179                 264 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0263574064312072 
                213                 306                 371                  46 
 0.0264531848242255  0.0264725347452019  0.0265044174029005  0.0266179390521136 
                166                 156                 409                 231 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0270745772651745  0.0272490757223059 
                200                 243                 210                 394 
           0.027375  0.0274423215573179  0.0274626865671642  0.0274893097128894 
                 86                 144                 113                  54 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609  0.0302711239799947   0.030411877394636 
                245                 169                 111                 266 
 0.0307638727652658  0.0308211473565804  0.0308783642812435  0.0312345066931086 
                 22                 114                 189                 168 
 0.0312998649809746   0.031352533722202   0.031377415351888  0.0314051164566628 
                351                 157                 254                 250 
 0.0315893385982231  0.0316351953842119  0.0316678395496129  0.0317272248551869 
                 97                 229                 230                 135 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0322131636508252 
                 56                  66                  58                 150 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0326864147088866  0.0327533265097236  0.0331766657450926  0.0332120109190173 
                 99                  13                 139                 353 
 0.0333333333333333  0.0339709257842387   0.034034034034034  0.0340782122905028 
                142                 122                 163                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0345318618725525  0.0346032855644879  0.0346534653465347  0.0347459003084916 
                135                  25                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629   0.035694612757519  0.0359856057576969   0.036105476673428 
                 76                 303                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0363489499192246 
                 70                 223                 183                 123 
 0.0365088419851683  0.0365853658536585   0.036608183005613  0.0366379310344828 
                169                 179                 188                 119 
 0.0367789392179636  0.0367839431449881  0.0368731563421829  0.0369127516778524 
                148                 168                  34                  26 
 0.0369810052109598  0.0369817341324224  0.0370029389894126  0.0370756402620608 
                198                 313                 167                  97 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0378919022889017  0.0379829731499673  0.0381717729784028  0.0382165605095541 
                114                 129                  89                   9 
 0.0382320029839612  0.0382728164867517  0.0383953168044077  0.0384615384615385 
                123                  39                 231                 348 
 0.0385852090032154  0.0386931402066889   0.038787023977433  0.0388998035363458 
                147                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0406144781144781  0.0408432147562582    0.04099560761347  0.0411866985437948 
                194                   9                 104                  56 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0413082980012114  0.0415162454873646  0.0415865384615385 
                298                 373                 368                 319 
 0.0416666666666667  0.0416754367501579    0.04203013481364  0.0421978021978022 
                153                 233                 384                 242 
 0.0422836752899197  0.0423121387283237  0.0425136916364987  0.0425763261129115 
                292                 187                  95                 335 
 0.0426995042379658  0.0431328036322361  0.0431638211196045  0.0432341381246491 
                197                 123                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454236366109071 
                310                 186                 158                 165 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012   0.047008547008547 
                221                 274                 226                 109 
 0.0470430107526882  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                 76                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494997367035282 
                165                 223                  98                 106 
 0.0496535796766744  0.0496568429551877  0.0497194815244728  0.0502816607552681 
                 37                 137                 135                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538535513119934  0.0538555691554468 
                131                 239                 278                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0569312169312169 
                129                 171                 220                 124 
 0.0571776155717762  0.0572625698324022  0.0574494949494949  0.0577124691399777 
                143                 208                 157                 443 
 0.0579365729738589  0.0579766536964981  0.0580472177728254   0.058057312988463 
                327                 225                 215                 454 
 0.0590868397493286  0.0594161801501251  0.0594954783436459  0.0601947477131897 
                214                  74                 271                 127 
 0.0603881058119328  0.0604450348721355  0.0605700712589074  0.0605714285714286 
                145                 263                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0641271581255138  0.0643896976483763  0.0645252183713722 
                341                  88                 157                 264 
 0.0645476772616137  0.0646551724137931  0.0646766169154229  0.0649717514124294 
                248                 223                 116                 333 
 0.0651982378854626  0.0654566518632941  0.0659246575342466   0.065989847715736 
                 49                 179                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676125848241826  0.0676933491284481  0.0678240740740741 
                200                 155                 256                 376 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0682505399568035 
                 74                 189                 163                 183 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0704392560348239 
                107                 287                 243                 135 
 0.0705556460811471  0.0710715061943056  0.0715539091440827  0.0718046912398277 
                 76                 125                 283                 175 
 0.0718416370106761  0.0722415428390768  0.0729649936735555  0.0730528709494031 
                154                 123                  72                  30 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0737867751395327 
                147                 227                 170                 332 
 0.0739031028851388  0.0739470173432438  0.0746185336806848   0.074849349825563 
                356                 206                 182                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0757384498863923 
                176                  72                 180                 329 
 0.0757575757575758  0.0761194029850746  0.0761608704099475  0.0761834556584725 
                 32                 162                 206                 238 
 0.0763305322128851              0.0765  0.0767867139391678  0.0771307365985345 
                147                 206                 404                 144 
 0.0772969491128418   0.077457264957265  0.0775623268698061   0.077792732166891 
                275                 178                 214                 292 
 0.0781227011917022  0.0792792792792793  0.0795300497062811  0.0795717592592593 
                243                 186                 189                 146 
 0.0797656602073006  0.0799757649197213  0.0800351802990325  0.0803679496489954 
                245                 126                 151                 203 
 0.0806698903172544  0.0808438558669541   0.081692573402418  0.0819262038774234 
                390                 174                 331                  81 
 0.0821148001605597  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 35                 205                  67                 171 
 0.0845241304933944  0.0850873264666368  0.0850877192982456   0.085838779956427 
                154                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0883005267535348 
                137                 330                 110                 310 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0918690601900739  0.0919729186043997  0.0920472328923033 
                224                 353                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0964261631827377 
                172                  80                 149                 181 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0984398216939079 
                195                 169                 295                  80 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102649006622517    0.10270393092479 
                269                 176                 184                 157 
  0.102815564694717   0.103008945513689   0.103597052549932   0.105719237435009 
                134                 167                 139                 119 
  0.105905511811024    0.10730054175318   0.108005366726297   0.108166470357283 
                345                 150                 171                 170 
  0.109404990403071   0.110151036178433   0.111923920994879   0.112025605852766 
                265                 190                 130                 202 
  0.112173739788803   0.114229765013055   0.114525835974502   0.114706592610481 
                178                  73                 198                 518 
  0.115978211529732   0.116141117702154   0.117099936431463   0.118951612903226 
                102                 230                 174                 142 
  0.119464797706276   0.120465801097577   0.121081745543946              0.1225 
                199                 328                 102                  73 
  0.122544159230289   0.123858909955167   0.124222197081118   0.125036689169357 
                 54                 269                 406                 261 
  0.125267338832875    0.12553251917069   0.126307739369838   0.126770467101959 
                175                 319                 204                 378 
  0.131510445635971   0.135149023638232   0.136729555838747   0.145816826598586 
                296                 234                 383                 388 
  0.146203845806626     0.1463243873979   0.148916657113378   0.152476213710661 
                188                 247                 211                 112 
  0.153031761308951   0.154871196536584   0.155465949820789    0.16151983045716 
                173                 210                 200                 186 
  0.162202043132804   0.163961038961039   0.164057181756297   0.167901234567901 
                454                 210                 196                 167 
  0.172022950473442   0.181258488003622   0.182134570765661   0.182632457871565 
                232                 190                 212                 294 
  0.184947958366693   0.185637891520244   0.189697630293488   0.198355345128333 
                211                 262                 218                 243 
  0.203438395415473    0.20463712781353   0.205955334987593   0.234804706537631 
                341                 276                 319                 229 
   0.25564486542374   0.261106454316848   0.279759519038076 
                237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2006

> round<-3

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167711021009952    0.01692628480314  0.0172651069685975  0.0172672341551625 
                366                 262                 273                 316 
 0.0172739541160594  0.0174939864421605  0.0174951994879454  0.0175423941191212 
                230                 536                 463                 252 
 0.0176991150442478  0.0177547118273696  0.0178211163416274  0.0178593575592211 
                194                 164                 119                 227 
 0.0178794178794179  0.0180489901160292  0.0180560891279293  0.0180937818552497 
                253                 370                 195                 156 
 0.0181434599156118  0.0182452374563992  0.0182575272261371  0.0186451971127152 
                278                 211                  17                 587 
 0.0186999343401182  0.0188848920863309  0.0194376952447067  0.0194924196145943 
                148                 242                 154                 206 
 0.0196571428571429  0.0197222222222222   0.019878902830464  0.0198854061341422 
                283                 296                 195                 159 
 0.0199234423280911  0.0199362041467305  0.0200785994998214  0.0201068974293713 
                511                 173                 248                 259 
 0.0205553552109629  0.0206237424547284   0.020628078817734  0.0206629358588033 
                344                 141                 328                  88 
 0.0207115701072462  0.0207501167194065  0.0208122398470019    0.02081526452732 
                150                 263                 172                 113 
 0.0208385638965604   0.020919175911252  0.0209403397866456  0.0210041364278107 
                180                 151                 190                 339 
 0.0211323866711337  0.0211568322981366  0.0211693548387097  0.0211998923863331 
                326                 394                   9                  56 
 0.0212652844231792  0.0214106769286397  0.0215326155794807  0.0215746707761278 
                162                 230                 124                  28 
 0.0216911764705882  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                  4                 450                 247                 273 
 0.0217859707924348  0.0217929668152551  0.0219236493825174  0.0219341974077767 
                291                 174                 145                  52 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230552952202437  0.0230622919638611  0.0231803430690774 
                281                 356                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234526191491455 
                244                 439                  76                 222 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0242544731610338  0.0243264977885002 
                163                 123                  61                 307 
 0.0243547800799709  0.0244668911335578  0.0244889267461669  0.0245016611295681 
                139                 154                 150                 121 
 0.0245203969128997  0.0246305418719212  0.0247417579018989   0.024763619990995 
                317                 109                 340                  86 
 0.0247737017627442  0.0248179120582681  0.0249746878164023  0.0251256281407035 
                115                 268                 166                 129 
 0.0251697962445066  0.0251836306400839  0.0251931417728382  0.0253712871287129 
                153                 144                 405                 297 
 0.0253881661770877   0.025439388079584  0.0254668930390492  0.0254880694143167 
                203                 323                 134                 179 
 0.0255052935514918  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                264                 187                 181                 259 
 0.0259743135518158   0.026079869600652  0.0261760937213985  0.0262657244913807 
                176                 213                 306                 371 
 0.0263574064312072  0.0264531848242255  0.0264725347452019  0.0265044174029005 
                 46                 166                 156                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0274423215573179  0.0274626865671642 
                394                  86                 144                 113 
 0.0274893097128894  0.0275103163686382  0.0275999116802826  0.0277726199633943 
                 54                 398                 320                 316 
 0.0279437271150511   0.027964785085448  0.0282313475062647   0.028270509977827 
                234                  65                 337                  65 
 0.0285470085470085  0.0286692340607617  0.0287486347324076   0.028899183763512 
                289                 290                 181                 135 
 0.0290282520956225  0.0291580880307162  0.0292200966996006  0.0292865871644684 
                 61                 120                 174                 331 
  0.029377657518361  0.0295295295295295  0.0295730980205104  0.0298372513562387 
                 95                 122                 247                 176 
 0.0298965967272362  0.0299936183790683  0.0299939283545841  0.0300218340611354 
                390                 326                 228                 366 
 0.0300982800982801   0.030188679245283  0.0301942222947609  0.0302686770207459 
                375                 245                 169                 317 
 0.0302711239799947   0.030411877394636  0.0307638727652658  0.0308211473565804 
                111                 266                  22                 114 
 0.0308783642812435  0.0312345066931086  0.0312998649809746   0.031352533722202 
                189                 168                 351                 157 
  0.031377415351888  0.0314051164566628  0.0315893385982231  0.0316351953842119 
                254                 250                  97                 229 
 0.0316678395496129  0.0317272248551869  0.0319337016574586  0.0320326150262085 
                230                 135                 332                  56 
 0.0320470415288497  0.0320665083135392  0.0322131636508252  0.0323421107482804 
                 66                  58                 150                 421 
 0.0325513638418647  0.0325693606755127  0.0326602346996686  0.0326864147088866 
                181                 166                 339                  99 
 0.0327533265097236  0.0331766657450926  0.0332120109190173  0.0333333333333333 
                 13                 139                 353                 142 
 0.0339709257842387   0.034034034034034  0.0340782122905028  0.0340900491865305 
                122                 163                  90                 421 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0345318618725525 
                235                 183                 180                 135 
 0.0346032855644879  0.0346534653465347  0.0347459003084916  0.0348244147157191 
                 25                  25                 203                 152 
 0.0348890414092885  0.0349115972430327  0.0350253807106599  0.0350921393607832 
                205                 291                  53                 160 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
  0.035694612757519  0.0359856057576969   0.036105476673428  0.0361134995700774 
                303                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0363489499192246  0.0365088419851683 
                223                 183                 123                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0378919022889017 
                334                  13                 260                 114 
 0.0379829731499673  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                129                  89                   9                 123 
 0.0382728164867517  0.0383953168044077  0.0384615384615385  0.0385852090032154 
                 39                 231                 348                 147 
 0.0386931402066889   0.038787023977433  0.0388998035363458  0.0389047933641635 
                178                 413                 201                 155 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0406144781144781 
                121                 213                 185                 194 
 0.0408432147562582    0.04099560761347  0.0411866985437948  0.0412392825206459 
                  9                 104                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415162454873646  0.0415865384615385  0.0416666666666667 
                373                 368                 319                 153 
 0.0416754367501579    0.04203013481364  0.0421978021978022  0.0422836752899197 
                233                 384                 242                 292 
 0.0423121387283237  0.0425136916364987  0.0425763261129115  0.0426995042379658 
                187                  95                 335                 197 
 0.0431328036322361  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                123                 221                 135                 312 
 0.0433574207893274  0.0434476279943636  0.0434699883302045  0.0435029049171036 
                209                 352                 515                 177 
 0.0435547734271887  0.0435933286727255  0.0436484634957917  0.0437311002558735 
                176                  83                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
 0.0443974630021142   0.044525215810995  0.0445749030296677  0.0448607345329061 
                125                 226                 328                 322 
 0.0449438202247191  0.0451125472198807  0.0452668098463572  0.0453118266330111 
                 27                 311                  54                 310 
 0.0453752181500873  0.0454081632653061  0.0454236366109071  0.0454771657160357 
                186                 158                 165                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012   0.047008547008547  0.0470430107526882 
                274                 226                 109                  76 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494997367035282  0.0496535796766744 
                223                  98                 106                  37 
 0.0496568429551877  0.0497194815244728  0.0502816607552681  0.0509113764927718 
                137                 135                 509                 224 
 0.0511221945137157  0.0512921525370312  0.0513173417223751  0.0513616687062777 
                141                 194                 410                 343 
 0.0516417910447761  0.0518164504653419  0.0519694944571114   0.052053981907163 
                154                 253                 147                 167 
 0.0522055664835289  0.0522119900389417  0.0522693757168606  0.0524006824274921 
                260                 394                 165                 285 
 0.0526157299679707  0.0526235972095845  0.0527306967984934   0.052766292577279 
                159                 204                  78                 135 
 0.0529287585522802  0.0529417416647984   0.053186119873817  0.0538116591928251 
                158                 305                 493                 131 
  0.053840499816244  0.0538535513119934  0.0538555691554468  0.0541211987798358 
                239                 278                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0557219892150989 
                141                 375                 283                 129 
 0.0568402950626782  0.0569210866752911  0.0569312169312169  0.0571776155717762 
                171                 220                 124                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0579766536964981  0.0579772385656002  0.0580472177728254   0.058057312988463 
                225                 184                 215                 454 
 0.0590868397493286  0.0594161801501251  0.0594954783436459  0.0601947477131897 
                214                  74                 271                 127 
 0.0603881058119328  0.0604450348721355  0.0605700712589074  0.0605714285714286 
                145                 263                  27                 150 
 0.0605864166749776  0.0606246548444499  0.0610859728506787   0.061569416498994 
                216                 210                 220                 111 
 0.0636079249217935  0.0636720453554296  0.0641271581255138  0.0643896976483763 
                341                 147                  88                 157 
 0.0645252183713722  0.0645476772616137  0.0646551724137931  0.0646766169154229 
                264                 248                 223                 116 
 0.0649717514124294  0.0651982378854626  0.0654566518632941   0.065705506972347 
                333                  49                 179                 176 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676125848241826 
                108                 140                 200                 155 
 0.0676933491284481  0.0678240740740741   0.067850348763475   0.068041136618414 
                256                 376                  74                 189 
 0.0681222707423581  0.0682505399568035  0.0683411214953271  0.0686325439266616 
                163                 183                 282                 224 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0715539091440827  0.0718046912398277  0.0718416370106761  0.0721442885771543 
                283                 175                 154                 359 
 0.0722415428390768  0.0728862973760933  0.0729649936735555  0.0730528709494031 
                123                  37                  72                  30 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0737867751395327 
                147                 227                 170                 332 
 0.0739031028851388  0.0739470173432438  0.0746185336806848   0.074849349825563 
                356                 206                 182                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0757384498863923 
                176                  72                 180                 329 
 0.0757575757575758  0.0761194029850746  0.0761608704099475  0.0761834556584725 
                 32                 162                 206                 238 
 0.0763305322128851              0.0765  0.0767867139391678  0.0771307365985345 
                147                 206                 404                 144 
 0.0772969491128418   0.077457264957265  0.0775623268698061   0.077792732166891 
                275                 178                 214                 292 
 0.0781227011917022  0.0792792792792793  0.0795300497062811  0.0795717592592593 
                243                 186                 189                 146 
 0.0797656602073006  0.0799757649197213  0.0800351802990325  0.0803679496489954 
                245                 126                 151                 203 
 0.0806698903172544  0.0808438558669541   0.081692573402418  0.0819262038774234 
                390                 174                 331                  81 
 0.0821148001605597  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 35                 205                  67                 171 
 0.0845241304933944  0.0850873264666368  0.0850877192982456   0.085838779956427 
                154                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0883005267535348 
                137                 330                 110                 310 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0918690601900739  0.0919729186043997  0.0920472328923033 
                224                 353                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0964261631827377 
                172                  80                 149                 181 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0984398216939079 
                195                 169                 295                  80 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102642276422764   0.102649006622517 
                269                 176                 111                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103597052549932 
                157                 134                 167                 139 
  0.105719237435009   0.105905511811024    0.10730054175318   0.108005366726297 
                119                 345                 150                 171 
  0.108166470357283   0.109404990403071   0.110151036178433   0.111923920994879 
                170                 265                 190                 130 
  0.112025605852766   0.112173739788803   0.114229765013055   0.114525835974502 
                202                 178                  73                 198 
  0.114706592610481   0.115978211529732   0.116141117702154   0.117099936431463 
                518                 102                 230                 174 
  0.118951612903226   0.119464797706276   0.120465801097577   0.121081745543946 
                142                 199                 328                 102 
             0.1225   0.122544159230289   0.123858909955167   0.124222197081118 
                 73                  54                 269                 406 
  0.125036689169357   0.125267338832875    0.12553251917069   0.126307739369838 
                261                 175                 319                 204 
  0.126770467101959   0.131510445635971   0.135149023638232   0.136729555838747 
                378                 296                 234                 383 
  0.145816826598586   0.146203845806626     0.1463243873979   0.148916657113378 
                388                 188                 247                 211 
  0.152476213710661   0.153031761308951   0.154871196536584   0.155465949820789 
                112                 173                 210                 200 
   0.16151983045716   0.162202043132804   0.163961038961039   0.164057181756297 
                186                 454                 210                 196 
  0.167901234567901   0.172022950473442   0.181258488003622   0.182134570765661 
                167                 232                 190                 212 
  0.182632457871565   0.184947958366693   0.185637891520244   0.189697630293488 
                294                 211                 262                 218 
  0.198355345128333   0.203438395415473    0.20463712781353   0.205955334987593 
                243                 341                 276                 319 
  0.234804706537631    0.25564486542374   0.261106454316848   0.279759519038076 
                229                 237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2008

> round<-4

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167084377610693  0.0167711021009952    0.01692628480314  0.0172651069685975 
                110                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176991150442478  0.0177547118273696  0.0178211163416274 
                252                 194                 164                 119 
 0.0178593575592211  0.0178794178794179  0.0180489901160292  0.0180560891279293 
                227                 253                 370                 195 
 0.0180937818552497  0.0181434599156118  0.0182452374563992  0.0182575272261371 
                156                 278                 211                  17 
 0.0186451971127152  0.0186999343401182  0.0188848920863309  0.0194376952447067 
                587                 148                 242                 154 
 0.0194924196145943  0.0196571428571429  0.0197222222222222   0.019878902830464 
                206                 283                 296                 195 
 0.0198854061341422  0.0199234423280911  0.0199362041467305  0.0199433304272014 
                159                 511                 173                 351 
 0.0200785994998214  0.0201068974293713  0.0205553552109629  0.0206237424547284 
                248                 259                 344                 141 
  0.020628078817734  0.0206629358588033  0.0207115701072462  0.0207501167194065 
                328                  88                 150                 263 
 0.0208122398470019    0.02081526452732  0.0208385638965604   0.020919175911252 
                172                 113                 180                 151 
 0.0209403397866456  0.0210041364278107  0.0211323866711337  0.0211568322981366 
                190                 339                 326                 394 
 0.0211693548387097  0.0211998923863331  0.0212652844231792  0.0214106769286397 
                  9                  56                 162                 230 
 0.0215326155794807  0.0215746707761278  0.0216911764705882  0.0217065004041104 
                124                  28                   4                 450 
 0.0217617659308621  0.0217782577393808  0.0217859707924348  0.0217929668152551 
                247                 273                 291                 174 
 0.0219236493825174  0.0219341974077767  0.0220403022670025  0.0220897615708275 
                145                  52                  83                 377 
 0.0222703371481596  0.0223612146352529  0.0224536670362744  0.0225645183083367 
                 20                 119                 109                 548 
 0.0226244343891403  0.0227412415488629  0.0230348401957961  0.0230552952202437 
                  3                  90                 281                 356 
 0.0230622919638611  0.0231803430690774  0.0232148695892754   0.023341049382716 
                127                 199                 244                 439 
 0.0233871878883742  0.0234526191491455  0.0234632323008031  0.0235011990407674 
                 76                 222                 136                 209 
 0.0235447283640055  0.0236710130391174  0.0237315875613748  0.0237923576063446 
                337                 216                 266                 475 
 0.0238816610229906  0.0239011309315612  0.0239206534422404  0.0241159646385855 
                 68                 227                 163                 123 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0244668911335578 
                 61                 307                 139                 154 
 0.0244889267461669  0.0245016611295681  0.0245203969128997  0.0246305418719212 
                150                 121                 317                 109 
 0.0247417579018989   0.024763619990995  0.0247737017627442  0.0248179120582681 
                340                  86                 115                 268 
 0.0249746878164023  0.0251256281407035  0.0251697962445066  0.0251836306400839 
                166                 129                 153                 144 
 0.0251931417728382  0.0253712871287129  0.0253881661770877   0.025439388079584 
                405                 297                 203                 323 
 0.0254668930390492  0.0254880694143167  0.0255052935514918  0.0255974508762613 
                134                 179                 264                 340 
 0.0256829707181417  0.0257529463116543  0.0257910706545297  0.0259743135518158 
                187                 181                 259                 176 
  0.026079869600652  0.0261760937213985  0.0262657244913807  0.0263574064312072 
                213                 306                 371                  46 
 0.0264531848242255  0.0264725347452019  0.0265044174029005  0.0266179390521136 
                166                 156                 409                 231 
 0.0266429840142096  0.0266724967205947  0.0267139027192646  0.0269498482955559 
                191                 198                 260                 175 
 0.0269736842105263  0.0270528760759667  0.0270745772651745  0.0272490757223059 
                200                 243                 210                 394 
           0.027375  0.0274423215573179  0.0274626865671642  0.0274893097128894 
                 86                 144                 113                  54 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609  0.0302686770207459  0.0302711239799947 
                245                 169                 317                 111 
  0.030411877394636  0.0307638727652658  0.0308211473565804  0.0308783642812435 
                266                  22                 114                 189 
 0.0312345066931086  0.0312998649809746   0.031352533722202   0.031377415351888 
                168                 351                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0319337016574586  0.0320326150262085  0.0320470415288497 
                135                 332                  56                  66 
 0.0320665083135392  0.0322131636508252  0.0323421107482804  0.0325513638418647 
                 58                 150                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339709257842387 
                139                 353                 142                 122 
  0.034034034034034  0.0340782122905028  0.0340900491865305  0.0343403607911324 
                163                  90                 421                 235 
 0.0344104070499371  0.0345168698109875  0.0345318618725525  0.0346032855644879 
                183                 180                 135                  25 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629   0.035694612757519 
                176                 132                  76                 303 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0363489499192246  0.0365088419851683  0.0365853658536585 
                183                 123                 169                 179 
  0.036608183005613  0.0366379310344828  0.0367789392179636  0.0367839431449881 
                188                 119                 148                 168 
 0.0368731563421829  0.0369127516778524  0.0369810052109598  0.0369817341324224 
                 34                  26                 198                 313 
 0.0370029389894126  0.0370756402620608  0.0371853546910755  0.0373638098364692 
                167                  97                 133                 334 
 0.0373705538045925  0.0375362566114997  0.0378919022889017  0.0379829731499673 
                 13                 260                 114                 129 
 0.0381717729784028  0.0382165605095541  0.0382320029839612  0.0382728164867517 
                 89                   9                 123                  39 
 0.0383953168044077  0.0384615384615385  0.0385852090032154  0.0386931402066889 
                231                 348                 147                 178 
  0.038787023977433  0.0388998035363458  0.0389047933641635  0.0389174319349488 
                413                 201                 155                 158 
 0.0391606080634501  0.0392809587217044  0.0395238095238095  0.0401267159450898 
                237                 232                 147                 121 
 0.0402792897631292  0.0403430749682338  0.0406144781144781  0.0408432147562582 
                213                 185                 194                   9 
   0.04099560761347  0.0411866985437948  0.0412392825206459  0.0412587412587413 
                104                  56                 120                 276 
 0.0412642669007902  0.0412852723944195  0.0412961567445365  0.0413082980012114 
                198                 235                 298                 373 
 0.0415162454873646  0.0415865384615385  0.0416666666666667  0.0416754367501579 
                368                 319                 153                 233 
   0.04203013481364  0.0421978021978022  0.0422836752899197  0.0423121387283237 
                384                 242                 292                 187 
 0.0425136916364987  0.0425763261129115  0.0426995042379658  0.0431328036322361 
                 95                 335                 197                 123 
 0.0431638211196045  0.0432341381246491  0.0433547898523287  0.0433574207893274 
                221                 135                 312                 209 
 0.0434476279943636  0.0434699883302045  0.0435029049171036  0.0435547734271887 
                352                 515                 177                 176 
 0.0435933286727255  0.0436484634957917  0.0437311002558735  0.0438813349814586 
                 83                 227                 225                 239 
 0.0439361466262656  0.0441482715535194  0.0442073170731707  0.0443974630021142 
                181                 137                  90                 125 
  0.044525215810995  0.0445749030296677  0.0448607345329061  0.0449438202247191 
                226                 328                 322                  27 
 0.0451125472198807  0.0452668098463572  0.0453118266330111  0.0453752181500873 
                311                  54                 310                 186 
 0.0454081632653061  0.0454236366109071  0.0454771657160357  0.0458015267175573 
                158                 165                 193                  53 
 0.0458288578589331  0.0461725394896719  0.0462850182704019  0.0463034418891804 
                427                 125                 102                  74 
 0.0463450600379187  0.0467409948542024  0.0467555821969129  0.0467714393215826 
                161                 221                 221                 274 
 0.0468945766959012   0.047008547008547  0.0470430107526882  0.0471818958155423 
                226                 109                  76                 170 
 0.0472636815920398  0.0473098330241187  0.0473145307359627   0.047542735042735 
                155                 127                 358                 302 
 0.0475452196382429  0.0477157360406091  0.0479256080114449   0.047961145401194 
                 62                  64                 140                 205 
 0.0482120051085568  0.0482456140350877  0.0483870967741935  0.0485338331185819 
                149                  35                 132                 165 
 0.0487106017191977  0.0492055356227576  0.0494505494505494  0.0494997367035282 
                223                  98                 165                 106 
 0.0496535796766744  0.0496568429551877  0.0497194815244728  0.0502816607552681 
                 37                 137                 135                 509 
 0.0509113764927718  0.0511221945137157  0.0512921525370312  0.0513173417223751 
                224                 141                 194                 410 
 0.0513616687062777  0.0516417910447761  0.0518164504653419  0.0519694944571114 
                343                 154                 253                 147 
  0.052053981907163  0.0522055664835289  0.0522119900389417  0.0522693757168606 
                167                 260                 394                 165 
 0.0524006824274921  0.0526157299679707  0.0526235972095845  0.0527306967984934 
                285                 159                 204                  78 
  0.052766292577279  0.0529287585522802  0.0529417416647984   0.053186119873817 
                135                 158                 305                 493 
 0.0538116591928251   0.053840499816244  0.0538535513119934  0.0538555691554468 
                131                 239                 278                 163 
 0.0541211987798358  0.0541623127830024  0.0542635658914729  0.0543535007831081 
                227                 225                 149                 181 
 0.0551325007614986  0.0551415797317437  0.0552183277853926  0.0555828824397442 
                239                 141                 375                 283 
 0.0556701030927835  0.0557219892150989  0.0568402950626782  0.0569210866752911 
                 41                 129                 171                 220 
 0.0569312169312169  0.0571776155717762  0.0572625698324022  0.0574494949494949 
                124                 143                 208                 157 
 0.0577124691399777  0.0579365729738589  0.0579766536964981  0.0579772385656002 
                443                 327                 225                 184 
 0.0580472177728254   0.058057312988463  0.0590868397493286  0.0594161801501251 
                215                 454                 214                  74 
 0.0594954783436459  0.0601947477131897  0.0603881058119328  0.0604450348721355 
                271                 127                 145                 263 
 0.0604914933837429  0.0605700712589074  0.0605714285714286  0.0605864166749776 
                160                  27                 150                 216 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0616624904673712 
                210                 220                 111                 316 
 0.0636079249217935  0.0636720453554296  0.0641271581255138  0.0643896976483763 
                341                 147                  88                 157 
 0.0645252183713722  0.0645476772616137  0.0646551724137931  0.0646766169154229 
                264                 248                 223                 116 
 0.0649717514124294  0.0651982378854626  0.0654566518632941   0.065705506972347 
                333                  49                 179                 176 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676125848241826 
                108                 140                 200                 155 
 0.0676933491284481  0.0678240740740741   0.067850348763475   0.068041136618414 
                256                 376                  74                 189 
 0.0681222707423581  0.0682505399568035  0.0683411214953271  0.0686325439266616 
                163                 183                 282                 224 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0715539091440827  0.0718046912398277  0.0718416370106761  0.0721442885771543 
                283                 175                 154                 359 
 0.0722415428390768  0.0728862973760933  0.0729649936735555  0.0730528709494031 
                123                  37                  72                  30 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0737867751395327 
                147                 227                 170                 332 
 0.0739031028851388  0.0739470173432438  0.0746185336806848   0.074849349825563 
                356                 206                 182                 127 
 0.0753043119455333  0.0755026672137874   0.075534556908353  0.0757384498863923 
                176                  72                 180                 329 
 0.0757575757575758  0.0761194029850746  0.0761608704099475  0.0761834556584725 
                 32                 162                 206                 238 
 0.0763305322128851              0.0765  0.0767867139391678  0.0771307365985345 
                147                 206                 404                 144 
 0.0772969491128418   0.077457264957265  0.0775623268698061   0.077792732166891 
                275                 178                 214                 292 
 0.0781227011917022  0.0792792792792793  0.0795300497062811  0.0795717592592593 
                243                 186                 189                 146 
 0.0797656602073006  0.0799757649197213  0.0800351802990325  0.0803679496489954 
                245                 126                 151                 203 
 0.0806698903172544  0.0808438558669541   0.081692573402418  0.0819262038774234 
                390                 174                 331                  81 
 0.0821148001605597  0.0821542674577818  0.0829190693974945  0.0845114315664221 
                 35                 205                  67                 171 
 0.0845241304933944  0.0850873264666368  0.0850877192982456   0.085838779956427 
                154                 181                 166                 169 
 0.0871771217712177  0.0871937608509935  0.0879211175020542  0.0883005267535348 
                137                 330                 110                 310 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0918690601900739  0.0919729186043997  0.0920472328923033 
                224                 353                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0964261631827377 
                172                  80                 149                 181 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0984398216939079 
                195                 169                 295                  80 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102642276422764   0.102649006622517 
                269                 176                 111                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103325799160478 
                157                 134                 167                 105 
  0.103597052549932   0.105719237435009   0.105905511811024    0.10730054175318 
                139                 119                 345                 150 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.111923920994879   0.112025605852766   0.112173739788803   0.114229765013055 
                130                 202                 178                  73 
  0.114525835974502   0.114706592610481   0.115978211529732   0.116141117702154 
                198                 518                 102                 230 
  0.117099936431463   0.118951612903226   0.119464797706276   0.120465801097577 
                174                 142                 199                 328 
  0.121081745543946              0.1225   0.122544159230289   0.123858909955167 
                102                  73                  54                 269 
  0.124222197081118   0.125036689169357   0.125267338832875    0.12553251917069 
                406                 261                 175                 319 
  0.126307739369838   0.126770467101959   0.131510445635971   0.135149023638232 
                204                 378                 296                 234 
  0.136729555838747   0.145816826598586   0.146203845806626     0.1463243873979 
                383                 388                 188                 247 
  0.148916657113378   0.152476213710661   0.153031761308951   0.154871196536584 
                211                 112                 173                 210 
  0.155465949820789    0.16151983045716   0.162202043132804   0.163961038961039 
                200                 186                 454                 210 
  0.164057181756297   0.167901234567901   0.172022950473442   0.181258488003622 
                196                 167                 232                 190 
  0.182134570765661   0.182632457871565   0.184947958366693   0.185637891520244 
                212                 294                 211                 262 
  0.189697630293488   0.198355345128333   0.203438395415473    0.20463712781353 
                218                 243                 341                 276 
  0.205955334987593   0.234804706537631    0.25564486542374   0.261106454316848 
                319                 229                 237                 234 
  0.279759519038076 
                219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2010

> round<-5

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167084377610693  0.0167711021009952    0.01692628480314  0.0172651069685975 
                110                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176991150442478  0.0177547118273696  0.0178211163416274 
                252                 194                 164                 119 
 0.0178593575592211  0.0178794178794179  0.0180489901160292  0.0180560891279293 
                227                 253                 370                 195 
 0.0180937818552497  0.0181434599156118  0.0182452374563992  0.0182575272261371 
                156                 278                 211                  17 
 0.0186451971127152  0.0186999343401182  0.0188848920863309  0.0191923230707717 
                587                 148                 242                  77 
 0.0194376952447067  0.0194924196145943  0.0196571428571429  0.0197222222222222 
                154                 206                 283                 296 
  0.019878902830464  0.0198854061341422  0.0199234423280911  0.0199362041467305 
                195                 159                 511                 173 
 0.0199433304272014  0.0200785994998214  0.0201068974293713  0.0205553552109629 
                351                 248                 259                 344 
 0.0206237424547284   0.020628078817734  0.0206629358588033  0.0207115701072462 
                141                 328                  88                 150 
 0.0207501167194065  0.0208122398470019    0.02081526452732  0.0208385638965604 
                263                 172                 113                 180 
  0.020919175911252  0.0209403397866456  0.0210041364278107  0.0211323866711337 
                151                 190                 339                 326 
 0.0211568322981366  0.0211693548387097  0.0211998923863331  0.0212652844231792 
                394                   9                  56                 162 
 0.0214106769286397  0.0215326155794807  0.0215746707761278  0.0216911764705882 
                230                 124                  28                   4 
 0.0217065004041104  0.0217617659308621  0.0217782577393808  0.0217859707924348 
                450                 247                 273                 291 
 0.0217929668152551  0.0219236493825174  0.0219341974077767  0.0220403022670025 
                174                 145                  52                  83 
 0.0220897615708275  0.0222703371481596  0.0223612146352529  0.0224536670362744 
                377                  20                 119                 109 
 0.0225645183083367  0.0226244343891403  0.0227412415488629  0.0230348401957961 
                548                   3                  90                 281 
 0.0230552952202437  0.0230622919638611  0.0231803430690774  0.0232148695892754 
                356                 127                 199                 244 
  0.023341049382716  0.0233871878883742  0.0234526191491455  0.0234632323008031 
                439                  76                 222                 136 
 0.0235011990407674  0.0235447283640055  0.0236710130391174  0.0237315875613748 
                209                 337                 216                 266 
 0.0237923576063446  0.0238816610229906  0.0239011309315612  0.0239206534422404 
                475                  68                 227                 163 
 0.0241159646385855  0.0242544731610338  0.0243264977885002  0.0243547800799709 
                123                  61                 307                 139 
 0.0244668911335578  0.0244889267461669  0.0245016611295681  0.0245203969128997 
                154                 150                 121                 317 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251256281407035  0.0251697962445066 
                268                 166                 129                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254668930390492  0.0254880694143167  0.0255052935514918 
                323                 134                 179                 264 
 0.0255974508762613  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                340                 187                 181                 259 
 0.0259743135518158   0.026079869600652  0.0261760937213985  0.0262657244913807 
                176                 213                 306                 371 
 0.0263574064312072  0.0264531848242255  0.0264725347452019  0.0265044174029005 
                 46                 166                 156                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0273822562979189  0.0274423215573179 
                394                  86                 266                 144 
 0.0274626865671642  0.0274893097128894  0.0275103163686382  0.0275999116802826 
                113                  54                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
 0.0302686770207459  0.0302711239799947   0.030411877394636  0.0307638727652658 
                317                 111                 266                  22 
 0.0308211473565804  0.0308783642812435  0.0312345066931086  0.0312998649809746 
                114                 189                 168                 351 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0319337016574586 
                229                 230                 135                 332 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0322131636508252 
                 56                  66                  58                 150 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0326864147088866  0.0327533265097236  0.0331766657450926  0.0332120109190173 
                 99                  13                 139                 353 
 0.0333333333333333  0.0339709257842387   0.034034034034034  0.0340782122905028 
                142                 122                 163                  90 
 0.0340900491865305  0.0343403607911324  0.0344104070499371  0.0345168698109875 
                421                 235                 183                 180 
 0.0345318618725525  0.0346032855644879  0.0346534653465347  0.0347459003084916 
                135                  25                  25                 203 
 0.0348244147157191  0.0348890414092885  0.0349115972430327  0.0350253807106599 
                152                 205                 291                  53 
 0.0350921393607832  0.0351497282512167  0.0351973182995581  0.0353383458646617 
                160                 406                 349                 267 
 0.0353873479983604    0.03547209181012  0.0354838709677419  0.0356401384083045 
                 69                  45                 176                 132 
 0.0356612184249629   0.035694612757519  0.0359856057576969   0.036105476673428 
                 76                 303                 242                 363 
 0.0361134995700774  0.0362391785786189  0.0362541993281075  0.0363489499192246 
                 70                 223                 183                 123 
 0.0365088419851683  0.0365853658536585   0.036608183005613  0.0366379310344828 
                169                 179                 188                 119 
 0.0367789392179636  0.0367839431449881  0.0368731563421829  0.0369127516778524 
                148                 168                  34                  26 
 0.0369810052109598  0.0369817341324224  0.0370029389894126  0.0370756402620608 
                198                 313                 167                  97 
 0.0371853546910755  0.0373638098364692  0.0373705538045925  0.0375362566114997 
                133                 334                  13                 260 
 0.0376263384369058  0.0378919022889017  0.0379829731499673  0.0381717729784028 
                295                 114                 129                  89 
 0.0382165605095541  0.0382320029839612  0.0382728164867517  0.0383953168044077 
                  9                 123                  39                 231 
 0.0384615384615385  0.0385852090032154  0.0386931402066889   0.038787023977433 
                348                 147                 178                 413 
 0.0388998035363458  0.0389047933641635  0.0389174319349488  0.0391606080634501 
                201                 155                 158                 237 
 0.0392809587217044  0.0395238095238095  0.0401267159450898  0.0402792897631292 
                232                 147                 121                 213 
 0.0403430749682338  0.0406144781144781  0.0408432147562582    0.04099560761347 
                185                 194                   9                 104 
 0.0411866985437948  0.0412392825206459  0.0412587412587413  0.0412642669007902 
                 56                 120                 276                 198 
 0.0412852723944195  0.0412961567445365  0.0413082980012114  0.0415162454873646 
                235                 298                 373                 368 
 0.0415865384615385  0.0416666666666667  0.0416754367501579    0.04203013481364 
                319                 153                 233                 384 
 0.0421978021978022  0.0422836752899197  0.0423121387283237  0.0425136916364987 
                242                 292                 187                  95 
 0.0425763261129115  0.0426995042379658  0.0431328036322361  0.0431638211196045 
                335                 197                 123                 221 
 0.0432341381246491  0.0433547898523287  0.0433574207893274  0.0434476279943636 
                135                 312                 209                 352 
 0.0434699883302045  0.0435029049171036  0.0435547734271887  0.0435933286727255 
                515                 177                 176                  83 
 0.0436484634957917  0.0437311002558735  0.0438813349814586  0.0439361466262656 
                227                 225                 239                 181 
 0.0441482715535194  0.0442073170731707  0.0443974630021142   0.044525215810995 
                137                  90                 125                 226 
 0.0445749030296677  0.0448607345329061  0.0449438202247191  0.0451125472198807 
                328                 322                  27                 311 
 0.0452668098463572  0.0453118266330111  0.0453752181500873  0.0454081632653061 
                 54                 310                 186                 158 
 0.0454236366109071  0.0454771657160357  0.0458015267175573  0.0458288578589331 
                165                 193                  53                 427 
 0.0461725394896719  0.0462850182704019  0.0463034418891804  0.0463450600379187 
                125                 102                  74                 161 
 0.0467409948542024  0.0467555821969129  0.0467714393215826  0.0468945766959012 
                221                 221                 274                 226 
  0.047008547008547  0.0470430107526882  0.0471818958155423  0.0472636815920398 
                109                  76                 170                 155 
 0.0473098330241187  0.0473145307359627   0.047542735042735  0.0475452196382429 
                127                 358                 302                  62 
 0.0477157360406091  0.0479256080114449   0.047961145401194  0.0482120051085568 
                 64                 140                 205                 149 
 0.0482456140350877  0.0483870967741935  0.0485338331185819  0.0487106017191977 
                 35                 132                 165                 223 
 0.0492055356227576  0.0494505494505494  0.0494997367035282  0.0496535796766744 
                 98                 165                 106                  37 
 0.0496568429551877  0.0497194815244728  0.0502816607552681  0.0509113764927718 
                137                 135                 509                 224 
 0.0511221945137157  0.0512921525370312  0.0513173417223751  0.0513616687062777 
                141                 194                 410                 343 
 0.0516417910447761  0.0518164504653419  0.0519694944571114   0.052053981907163 
                154                 253                 147                 167 
 0.0522055664835289  0.0522119900389417  0.0522693757168606  0.0524006824274921 
                260                 394                 165                 285 
 0.0526157299679707  0.0526235972095845  0.0527306967984934   0.052766292577279 
                159                 204                  78                 135 
 0.0529287585522802  0.0529417416647984   0.053186119873817  0.0538116591928251 
                158                 305                 493                 131 
  0.053840499816244  0.0538535513119934  0.0538555691554468  0.0541211987798358 
                239                 278                 163                 227 
 0.0541623127830024  0.0542635658914729  0.0543535007831081  0.0551325007614986 
                225                 149                 181                 239 
 0.0551415797317437  0.0552183277853926  0.0555828824397442  0.0556701030927835 
                141                 375                 283                  41 
 0.0557219892150989  0.0568402950626782  0.0569210866752911  0.0569312169312169 
                129                 171                 220                 124 
 0.0571776155717762  0.0572625698324022  0.0574494949494949  0.0577124691399777 
                143                 208                 157                 443 
 0.0579365729738589  0.0579766536964981  0.0579772385656002  0.0580472177728254 
                327                 225                 184                 215 
  0.058057312988463  0.0590868397493286  0.0594161801501251  0.0594954783436459 
                454                 214                  74                 271 
 0.0601947477131897  0.0603881058119328  0.0604450348721355  0.0604914933837429 
                127                 145                 263                 160 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606246548444499 
                 27                 150                 216                 210 
 0.0610859728506787   0.061569416498994  0.0616624904673712  0.0636079249217935 
                220                 111                 316                 341 
 0.0636720453554296  0.0641271581255138  0.0643896976483763  0.0645252183713722 
                147                  88                 157                 264 
 0.0645476772616137  0.0646551724137931  0.0646766169154229  0.0649717514124294 
                248                 223                 116                 333 
 0.0651982378854626  0.0654566518632941   0.065705506972347  0.0657229524772497 
                 49                 179                 176                  37 
 0.0659246575342466   0.065989847715736  0.0662208091218068  0.0663316582914573 
                214                 104                 154                  50 
  0.066402490801019  0.0664614270191959  0.0668523676880223  0.0676125848241826 
                108                 140                 200                 155 
 0.0676933491284481  0.0678240740740741   0.067850348763475   0.068041136618414 
                256                 376                  74                 189 
 0.0681222707423581  0.0682505399568035  0.0683411214953271  0.0686325439266616 
                163                 183                 282                 224 
 0.0691271525139389  0.0691703391454302   0.069882777276826  0.0701461377870564 
                160                 148                 107                 287 
 0.0702966470190357  0.0704392560348239  0.0705556460811471  0.0710715061943056 
                243                 135                  76                 125 
 0.0715539091440827  0.0718046912398277  0.0718416370106761  0.0721442885771543 
                283                 175                 154                 359 
 0.0722415428390768  0.0728862973760933  0.0729649936735555  0.0730528709494031 
                123                  37                  72                  30 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0737867751395327 
                147                 227                 170                 332 
 0.0739031028851388  0.0739470173432438  0.0744658345673789  0.0746185336806848 
                356                 206                 130                 182 
  0.074849349825563  0.0753043119455333  0.0755026672137874   0.075534556908353 
                127                 176                  72                 180 
 0.0757384498863923  0.0757575757575758  0.0761194029850746  0.0761608704099475 
                329                  32                 162                 206 
 0.0761834556584725  0.0763305322128851              0.0765  0.0767867139391678 
                238                 147                 206                 404 
 0.0771307365985345  0.0772969491128418   0.077457264957265  0.0775623268698061 
                144                 275                 178                 214 
  0.077766445690974   0.077792732166891  0.0781227011917022  0.0792792792792793 
                110                 292                 243                 186 
 0.0795300497062811  0.0795717592592593  0.0797656602073006  0.0799757649197213 
                189                 146                 245                 126 
 0.0800351802990325  0.0803679496489954  0.0806698903172544  0.0808438558669541 
                151                 203                 390                 174 
  0.081692573402418  0.0819262038774234  0.0821148001605597  0.0821542674577818 
                331                  81                  35                 205 
 0.0829190693974945  0.0845114315664221  0.0845241304933944  0.0850873264666368 
                 67                 171                 154                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0872557726465364  0.0879211175020542  0.0880537203509152  0.0883005267535348 
                128                 110                 289                 310 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0918690601900739  0.0919729186043997  0.0920472328923033 
                224                 353                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0964261631827377 
                172                  80                 149                 181 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0984398216939079 
                195                 169                 295                  80 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102642276422764   0.102649006622517 
                269                 176                 111                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103325799160478 
                157                 134                 167                 105 
  0.103597052549932   0.105719237435009   0.105905511811024    0.10730054175318 
                139                 119                 345                 150 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.111923920994879   0.112025605852766   0.112173739788803   0.114229765013055 
                130                 202                 178                  73 
  0.114525835974502   0.114706592610481   0.115978211529732   0.116141117702154 
                198                 518                 102                 230 
  0.117099936431463   0.118951612903226   0.119464797706276   0.120465801097577 
                174                 142                 199                 328 
  0.121081745543946              0.1225   0.122544159230289   0.123858909955167 
                102                  73                  54                 269 
  0.124222197081118   0.125036689169357   0.125267338832875    0.12553251917069 
                406                 261                 175                 319 
  0.126307739369838   0.126770467101959   0.131510445635971   0.135149023638232 
                204                 378                 296                 234 
  0.136729555838747   0.145720649061406   0.145816826598586   0.146203845806626 
                383                  95                 388                 188 
    0.1463243873979   0.148916657113378   0.152476213710661   0.153031761308951 
                247                 211                 112                 173 
  0.154871196536584   0.155465949820789    0.16151983045716   0.162202043132804 
                210                 200                 186                 454 
  0.163961038961039   0.164057181756297   0.167901234567901   0.172022950473442 
                210                 196                 167                 232 
  0.181258488003622   0.182134570765661   0.182632457871565   0.184947958366693 
                190                 212                 294                 211 
  0.185637891520244   0.189697630293488   0.198355345128333   0.203438395415473 
                262                 218                 243                 341 
   0.20463712781353   0.205955334987593   0.234804706537631    0.25564486542374 
                276                 319                 229                 237 
  0.261106454316848   0.279759519038076 
                234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2012

> round<-6

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167084377610693  0.0167711021009952    0.01692628480314  0.0172651069685975 
                110                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176535490989334  0.0176991150442478  0.0177547118273696 
                252                 125                 194                 164 
 0.0178211163416274  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                119                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0182452374563992 
                195                 156                 278                 211 
 0.0182575272261371  0.0186451971127152  0.0186999343401182  0.0188848920863309 
                 17                 587                 148                 242 
 0.0191923230707717  0.0194376952447067  0.0194924196145943  0.0196571428571429 
                 77                 154                 206                 283 
 0.0197222222222222   0.019878902830464  0.0198854061341422  0.0199234423280911 
                296                 195                 159                 511 
 0.0199362041467305  0.0199433304272014  0.0200785994998214  0.0201068974293713 
                173                 351                 248                 259 
 0.0205553552109629  0.0206237424547284   0.020628078817734  0.0206629358588033 
                344                 141                 328                  88 
 0.0207115701072462  0.0207501167194065  0.0208122398470019    0.02081526452732 
                150                 263                 172                 113 
 0.0208385638965604   0.020919175911252  0.0209403397866456  0.0210041364278107 
                180                 151                 190                 339 
 0.0211323866711337  0.0211568322981366  0.0211693548387097  0.0211998923863331 
                326                 394                   9                  56 
 0.0212652844231792  0.0214106769286397  0.0215326155794807  0.0215746707761278 
                162                 230                 124                  28 
 0.0216911764705882  0.0217065004041104  0.0217617659308621  0.0217782577393808 
                  4                 450                 247                 273 
 0.0217859707924348  0.0217929668152551  0.0219236493825174  0.0219341974077767 
                291                 174                 145                  52 
 0.0220403022670025  0.0220897615708275  0.0222703371481596  0.0223612146352529 
                 83                 377                  20                 119 
 0.0224536670362744  0.0225645183083367  0.0226244343891403  0.0227412415488629 
                109                 548                   3                  90 
 0.0230348401957961  0.0230552952202437  0.0230622919638611  0.0231803430690774 
                281                 356                 127                 199 
 0.0232148695892754   0.023341049382716  0.0233871878883742  0.0234526191491455 
                244                 439                  76                 222 
 0.0234632323008031  0.0235011990407674  0.0235447283640055  0.0236710130391174 
                136                 209                 337                 216 
 0.0237315875613748  0.0237923576063446  0.0238816610229906  0.0239011309315612 
                266                 475                  68                 227 
 0.0239206534422404  0.0241159646385855  0.0241173545499751  0.0242544731610338 
                163                 123                 352                  61 
 0.0243264977885002  0.0243547800799709  0.0244668911335578  0.0244889267461669 
                307                 139                 154                 150 
 0.0245016611295681  0.0245203969128997  0.0246305418719212  0.0247417579018989 
                121                 317                 109                 340 
  0.024763619990995  0.0247737017627442  0.0248179120582681  0.0249746878164023 
                 86                 115                 268                 166 
 0.0251256281407035  0.0251697962445066  0.0251836306400839  0.0251931417728382 
                129                 153                 144                 405 
 0.0253712871287129  0.0253881661770877   0.025439388079584  0.0254668930390492 
                297                 203                 323                 134 
 0.0254880694143167  0.0255052935514918  0.0255974508762613  0.0256829707181417 
                179                 264                 340                 187 
 0.0257529463116543  0.0257910706545297  0.0259743135518158   0.026079869600652 
                181                 259                 176                 213 
 0.0261760937213985  0.0262657244913807  0.0263574064312072  0.0264531848242255 
                306                 371                  46                 166 
 0.0264725347452019  0.0265044174029005  0.0266179390521136  0.0266429840142096 
                156                 409                 231                 191 
 0.0266724967205947  0.0267139027192646  0.0269498482955559  0.0269736842105263 
                198                 260                 175                 200 
 0.0270528760759667  0.0270745772651745  0.0272490757223059            0.027375 
                243                 210                 394                  86 
 0.0273822562979189  0.0274423215573179  0.0274626865671642  0.0274893097128894 
                266                 144                 113                  54 
 0.0275103163686382  0.0275999116802826  0.0277726199633943  0.0279437271150511 
                398                 320                 316                 234 
  0.027964785085448  0.0282313475062647   0.028270509977827  0.0285470085470085 
                 65                 337                  65                 289 
 0.0286692340607617  0.0287486347324076   0.028899183763512  0.0290282520956225 
                290                 181                 135                  61 
 0.0291580880307162  0.0292200966996006  0.0292865871644684   0.029377657518361 
                120                 174                 331                  95 
 0.0295295295295295  0.0295730980205104  0.0298372513562387  0.0298965967272362 
                122                 247                 176                 390 
 0.0299936183790683  0.0299939283545841  0.0300218340611354  0.0300982800982801 
                326                 228                 366                 375 
  0.030188679245283  0.0301942222947609  0.0302686770207459  0.0302711239799947 
                245                 169                 317                 111 
  0.030411877394636  0.0307638727652658  0.0308211473565804  0.0308783642812435 
                266                  22                 114                 189 
 0.0312345066931086  0.0312998649809746   0.031352533722202   0.031377415351888 
                168                 351                 157                 254 
 0.0314051164566628  0.0315893385982231  0.0316351953842119  0.0316678395496129 
                250                  97                 229                 230 
 0.0317272248551869  0.0319337016574586  0.0320326150262085  0.0320470415288497 
                135                 332                  56                  66 
 0.0320665083135392  0.0322131636508252  0.0323421107482804  0.0325513638418647 
                 58                 150                 421                 181 
 0.0325693606755127  0.0326602346996686  0.0326864147088866  0.0327533265097236 
                166                 339                  99                  13 
 0.0331766657450926  0.0332120109190173  0.0333333333333333  0.0339471376675435 
                139                 353                 142                 299 
 0.0339709257842387   0.034034034034034  0.0340782122905028  0.0340900491865305 
                122                 163                  90                 421 
 0.0343403607911324  0.0344104070499371  0.0345168698109875  0.0345318618725525 
                235                 183                 180                 135 
 0.0346032855644879  0.0346534653465347  0.0347459003084916  0.0348244147157191 
                 25                  25                 203                 152 
 0.0348890414092885  0.0349115972430327  0.0350253807106599  0.0350921393607832 
                205                 291                  53                 160 
 0.0351497282512167  0.0351973182995581  0.0353383458646617  0.0353873479983604 
                406                 349                 267                  69 
   0.03547209181012  0.0354838709677419  0.0356401384083045  0.0356612184249629 
                 45                 176                 132                  76 
  0.035694612757519  0.0359856057576969   0.036105476673428  0.0361134995700774 
                303                 242                 363                  70 
 0.0362391785786189  0.0362541993281075  0.0363489499192246  0.0365088419851683 
                223                 183                 123                 169 
 0.0365853658536585   0.036608183005613  0.0366379310344828  0.0367789392179636 
                179                 188                 119                 148 
 0.0367839431449881  0.0368731563421829  0.0369127516778524  0.0369810052109598 
                168                  34                  26                 198 
 0.0369817341324224  0.0370029389894126  0.0370756402620608  0.0371853546910755 
                313                 167                  97                 133 
 0.0373638098364692  0.0373705538045925  0.0375362566114997  0.0376263384369058 
                334                  13                 260                 295 
 0.0378919022889017  0.0379829731499673  0.0381717729784028  0.0382165605095541 
                114                 129                  89                   9 
 0.0382320029839612  0.0382728164867517  0.0383953168044077  0.0384615384615385 
                123                  39                 231                 348 
 0.0385852090032154  0.0386931402066889   0.038787023977433  0.0388998035363458 
                147                 178                 413                 201 
 0.0389047933641635  0.0389174319349488  0.0391606080634501  0.0392809587217044 
                155                 158                 237                 232 
 0.0395238095238095  0.0401267159450898  0.0402792897631292  0.0403430749682338 
                147                 121                 213                 185 
 0.0406144781144781  0.0408432147562582    0.04099560761347  0.0411866985437948 
                194                   9                 104                  56 
 0.0412392825206459  0.0412587412587413  0.0412642669007902  0.0412852723944195 
                120                 276                 198                 235 
 0.0412961567445365  0.0413082980012114  0.0415162454873646  0.0415865384615385 
                298                 373                 368                 319 
 0.0416666666666667  0.0416754367501579    0.04203013481364  0.0421978021978022 
                153                 233                 384                 242 
 0.0422836752899197  0.0423121387283237  0.0425136916364987  0.0425763261129115 
                292                 187                  95                 335 
 0.0426995042379658  0.0431328036322361  0.0431638211196045  0.0432341381246491 
                197                 123                 221                 135 
 0.0433547898523287  0.0433574207893274  0.0434476279943636  0.0434699883302045 
                312                 209                 352                 515 
 0.0435029049171036  0.0435547734271887  0.0435933286727255  0.0436484634957917 
                177                 176                  83                 227 
 0.0437311002558735  0.0438813349814586  0.0439361466262656  0.0441482715535194 
                225                 239                 181                 137 
 0.0442073170731707  0.0443974630021142   0.044525215810995  0.0445749030296677 
                 90                 125                 226                 328 
 0.0448607345329061  0.0449438202247191  0.0451125472198807  0.0452668098463572 
                322                  27                 311                  54 
 0.0453118266330111  0.0453752181500873  0.0454081632653061  0.0454236366109071 
                310                 186                 158                 165 
 0.0454771657160357  0.0458015267175573  0.0458288578589331  0.0461725394896719 
                193                  53                 427                 125 
 0.0462850182704019  0.0463034418891804  0.0463450600379187  0.0467409948542024 
                102                  74                 161                 221 
 0.0467555821969129  0.0467714393215826  0.0468945766959012   0.047008547008547 
                221                 274                 226                 109 
 0.0470430107526882  0.0471818958155423  0.0472636815920398  0.0473098330241187 
                 76                 170                 155                 127 
 0.0473145307359627   0.047542735042735  0.0475452196382429  0.0477157360406091 
                358                 302                  62                  64 
 0.0479256080114449   0.047961145401194  0.0482120051085568  0.0482456140350877 
                140                 205                 149                  35 
 0.0483870967741935  0.0485338331185819  0.0487106017191977  0.0492055356227576 
                132                 165                 223                  98 
 0.0494505494505494  0.0494997367035282  0.0496535796766744  0.0496568429551877 
                165                 106                  37                 137 
 0.0497194815244728  0.0502816607552681  0.0509113764927718  0.0511221945137157 
                135                 509                 224                 141 
 0.0512921525370312  0.0513173417223751  0.0513616687062777  0.0516417910447761 
                194                 410                 343                 154 
 0.0518164504653419  0.0519694944571114   0.052053981907163  0.0522055664835289 
                253                 147                 167                 260 
 0.0522119900389417  0.0522693757168606  0.0524006824274921  0.0526157299679707 
                394                 165                 285                 159 
 0.0526235972095845  0.0527306967984934   0.052766292577279  0.0529287585522802 
                204                  78                 135                 158 
 0.0529417416647984   0.053186119873817  0.0538116591928251   0.053840499816244 
                305                 493                 131                 239 
 0.0538535513119934  0.0538555691554468  0.0541211987798358  0.0541623127830024 
                278                 163                 227                 225 
 0.0542635658914729  0.0543535007831081  0.0551325007614986  0.0551415797317437 
                149                 181                 239                 141 
 0.0552183277853926  0.0555828824397442  0.0556701030927835  0.0557219892150989 
                375                 283                  41                 129 
 0.0568402950626782  0.0569210866752911  0.0569312169312169  0.0571776155717762 
                171                 220                 124                 143 
 0.0572625698324022  0.0574494949494949  0.0577124691399777  0.0579365729738589 
                208                 157                 443                 327 
 0.0579766536964981  0.0579772385656002  0.0580472177728254   0.058057312988463 
                225                 184                 215                 454 
 0.0590868397493286  0.0594161801501251  0.0594954783436459  0.0601947477131897 
                214                  74                 271                 127 
 0.0602798708288482  0.0603881058119328  0.0604450348721355  0.0604914933837429 
                 33                 145                 263                 160 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606119664782693 
                 27                 150                 216                 160 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0616624904673712 
                210                 220                 111                 316 
 0.0636079249217935  0.0636720453554296  0.0641271581255138  0.0643896976483763 
                341                 147                  88                 157 
 0.0645252183713722  0.0645476772616137  0.0646551724137931  0.0646766169154229 
                264                 248                 223                 116 
 0.0649717514124294  0.0651982378854626  0.0654566518632941   0.065705506972347 
                333                  49                 179                 176 
 0.0657229524772497  0.0659246575342466   0.065989847715736  0.0662208091218068 
                 37                 214                 104                 154 
 0.0663316582914573   0.066402490801019  0.0664614270191959  0.0668523676880223 
                 50                 108                 140                 200 
 0.0676125848241826  0.0676933491284481  0.0678240740740741   0.067850348763475 
                155                 256                 376                  74 
  0.068041136618414  0.0681222707423581  0.0682505399568035  0.0683411214953271 
                189                 163                 183                 282 
 0.0686325439266616  0.0691271525139389  0.0691703391454302   0.069882777276826 
                224                 160                 148                 107 
 0.0701461377870564  0.0702966470190357  0.0703940720781408  0.0704392560348239 
                287                 243                 114                 135 
 0.0705556460811471  0.0710715061943056  0.0715539091440827  0.0718046912398277 
                 76                 125                 283                 175 
 0.0718416370106761  0.0721442885771543  0.0722415428390768  0.0728862973760933 
                154                 359                 123                  37 
 0.0729649936735555  0.0730528709494031  0.0731810490693739  0.0734780628510703 
                 72                  30                 147                 227 
 0.0735163861824624  0.0737867751395327  0.0739031028851388  0.0739470173432438 
                170                 332                 356                 206 
 0.0744658345673789  0.0746185336806848   0.074849349825563  0.0753043119455333 
                130                 182                 127                 176 
 0.0755026672137874   0.075534556908353  0.0757384498863923  0.0757575757575758 
                 72                 180                 329                  32 
 0.0761194029850746  0.0761608704099475  0.0761834556584725  0.0763305322128851 
                162                 206                 238                 147 
             0.0765  0.0767867139391678  0.0771307365985345  0.0772969491128418 
                206                 404                 144                 275 
  0.077457264957265  0.0775623268698061   0.077766445690974   0.077792732166891 
                178                 214                 110                 292 
 0.0781227011917022  0.0792792792792793  0.0795259032689734  0.0795300497062811 
                243                 186                 408                 189 
 0.0795717592592593  0.0797656602073006  0.0799757649197213  0.0800351802990325 
                146                 245                 126                 151 
 0.0803679496489954  0.0806698903172544  0.0808438558669541   0.081692573402418 
                203                 390                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0845241304933944  0.0846036585365854  0.0850873264666368 
                171                 154                 125                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0872557726465364  0.0879211175020542  0.0880537203509152  0.0883005267535348 
                128                 110                 289                 310 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0918690601900739  0.0919729186043997  0.0920472328923033 
                224                 353                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0964261631827377 
                172                  80                 149                 181 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0984398216939079 
                195                 169                 295                  80 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102642276422764   0.102649006622517 
                269                 176                 111                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103325799160478 
                157                 134                 167                 105 
  0.103597052549932   0.105719237435009   0.105905511811024    0.10730054175318 
                139                 119                 345                 150 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.111923920994879   0.112025605852766   0.112173739788803   0.114229765013055 
                130                 202                 178                  73 
  0.114525835974502   0.114706592610481   0.115978211529732   0.116141117702154 
                198                 518                 102                 230 
  0.117099936431463   0.118951612903226   0.119464797706276   0.120465801097577 
                174                 142                 199                 328 
  0.121081745543946              0.1225   0.122544159230289   0.123858909955167 
                102                  73                  54                 269 
  0.124222197081118   0.125036689169357   0.125267338832875    0.12553251917069 
                406                 261                 175                 319 
  0.126307739369838   0.126770467101959   0.131510445635971   0.135149023638232 
                204                 378                 296                 234 
  0.136729555838747   0.145720649061406   0.145816826598586   0.146203845806626 
                383                  95                 388                 188 
    0.1463243873979   0.147475481293135   0.148916657113378   0.152476213710661 
                247                 121                 211                 112 
  0.153031761308951   0.154871196536584   0.155465949820789    0.16151983045716 
                173                 210                 200                 186 
  0.162202043132804   0.163961038961039   0.164057181756297   0.167901234567901 
                454                 210                 196                 167 
  0.172022950473442   0.181258488003622   0.182134570765661   0.182632457871565 
                232                 190                 212                 294 
  0.184947958366693   0.185637891520244   0.189697630293488   0.198355345128333 
                211                 262                 218                 243 
  0.203438395415473    0.20463712781353   0.205955334987593   0.234804706537631 
                341                 276                 319                 229 
   0.25564486542374   0.261106454316848   0.279759519038076 
                237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Change year
> year=2014

> round<-7

> isco<-"Armed forces occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Clerical support workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Craft and related trades workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Elementary occupations"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Managers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Plant and machine operators and assemblers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Service and sales workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Skilled agricultural, forestry and fishery workers"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> ##########################
> 
> 
> isco<-"Technicians and associate professionals"

> Empl.country<-as.numeric(gsub(",", "",as.character(
+   factor(Empl$Value[Empl$GEO==country&Empl$TIME==year&Empl$ISCO08==isco][1]
+          , exclude = 0))))

> UE.country<-as.numeric(gsub(",", "",as.character(factor(
+   UE_occu$Value[UE_occu$GEO==country&UE_occu$TIME==year&UE_occu$ISCO08==isco][1]
+   , exclude = 0))))

> data$risk[data$occupation==isco&data$cntry==cntry&data$essround==round]<-
+   UE.country/(UE.country+Empl.country)

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167084377610693  0.0167711021009952    0.01692628480314  0.0172651069685975 
                110                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176535490989334  0.0176991150442478  0.0177547118273696 
                252                 125                 194                 164 
 0.0178211163416274  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                119                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0181750741839763 
                195                 156                 278                 108 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0191923230707717  0.0194376952447067  0.0194924196145943 
                242                  77                 154                 206 
 0.0196571428571429  0.0197222222222222   0.019878902830464  0.0198854061341422 
                283                 296                 195                 159 
 0.0199234423280911  0.0199362041467305  0.0199433304272014  0.0200785994998214 
                511                 173                 351                 248 
 0.0201068974293713  0.0205553552109629  0.0206237424547284   0.020628078817734 
                259                 344                 141                 328 
 0.0206629358588033  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                 88                 150                 263                 172 
   0.02081526452732  0.0208385638965604   0.020919175911252  0.0209403397866456 
                113                 180                 151                 190 
 0.0210041364278107  0.0211323866711337  0.0211568322981366  0.0211693548387097 
                339                 326                 394                   9 
 0.0211998923863331  0.0212652844231792  0.0214106769286397  0.0215326155794807 
                 56                 162                 230                 124 
 0.0215746707761278  0.0216911764705882  0.0217065004041104  0.0217617659308621 
                 28                   4                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0219341974077767  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                 52                  83                 377                  20 
 0.0223612146352529  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                119                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230552952202437  0.0230622919638611 
                 90                 281                 356                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0241173545499751 
                227                 163                 123                 352 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0244668911335578 
                 61                 307                 139                 154 
 0.0244889267461669  0.0245016611295681  0.0245203969128997   0.024554269627776 
                150                 121                 317                 443 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251256281407035  0.0251697962445066 
                268                 166                 129                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254668930390492  0.0254880694143167  0.0255052935514918 
                323                 134                 179                 264 
 0.0255974508762613  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                340                 187                 181                 259 
 0.0259743135518158   0.026079869600652  0.0261760937213985  0.0262657244913807 
                176                 213                 306                 371 
 0.0263574064312072  0.0264531848242255  0.0264725347452019  0.0265044174029005 
                 46                 166                 156                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0273822562979189  0.0274423215573179 
                394                  86                 266                 144 
 0.0274626865671642  0.0274893097128894  0.0275103163686382  0.0275999116802826 
                113                  54                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
 0.0302686770207459  0.0302711239799947   0.030411877394636  0.0307638727652658 
                317                 111                 266                  22 
 0.0308211473565804  0.0308783642812435  0.0312345066931086  0.0312998649809746 
                114                 189                 168                 351 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0319337016574586 
                229                 230                 135                 332 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0322131636508252 
                 56                  66                  58                 150 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0326864147088866  0.0327533265097236  0.0331766657450926  0.0332120109190173 
                 99                  13                 139                 353 
 0.0333333333333333  0.0339471376675435  0.0339709257842387   0.034034034034034 
                142                 299                 122                 163 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346032855644879  0.0346285714285714 
                180                 135                  25                 281 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629   0.035694612757519 
                176                 132                  76                 303 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0363489499192246  0.0365088419851683  0.0365853658536585 
                183                 123                 169                 179 
  0.036608183005613  0.0366379310344828  0.0367789392179636  0.0367839431449881 
                188                 119                 148                 168 
 0.0368731563421829  0.0369127516778524  0.0369810052109598  0.0369817341324224 
                 34                  26                 198                 313 
 0.0370029389894126  0.0370756402620608  0.0371853546910755  0.0373638098364692 
                167                  97                 133                 334 
 0.0373705538045925  0.0375362566114997  0.0376263384369058  0.0378919022889017 
                 13                 260                 295                 114 
 0.0379829731499673  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                129                  89                   9                 123 
 0.0382728164867517  0.0383953168044077  0.0384615384615385  0.0385852090032154 
                 39                 231                 348                 147 
 0.0386931402066889   0.038787023977433  0.0388998035363458  0.0389047933641635 
                178                 413                 201                 155 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0406144781144781 
                121                 213                 185                 194 
 0.0408432147562582    0.04099560761347  0.0411866985437948  0.0412392825206459 
                  9                 104                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415162454873646  0.0415865384615385  0.0416666666666667 
                373                 368                 319                 153 
 0.0416754367501579    0.04203013481364  0.0421978021978022  0.0422836752899197 
                233                 384                 242                 292 
 0.0423121387283237  0.0425136916364987  0.0425763261129115  0.0426995042379658 
                187                  95                 335                 197 
 0.0431328036322361  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                123                 221                 135                 312 
 0.0433574207893274  0.0434476279943636  0.0434699883302045  0.0435029049171036 
                209                 352                 515                 177 
 0.0435547734271887  0.0435933286727255  0.0436484634957917  0.0437311002558735 
                176                  83                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
 0.0443974630021142   0.044525215810995  0.0445749030296677  0.0448607345329061 
                125                 226                 328                 322 
 0.0449438202247191  0.0451125472198807  0.0452668098463572  0.0453118266330111 
                 27                 311                  54                 310 
 0.0453752181500873  0.0454081632653061  0.0454236366109071  0.0454771657160357 
                186                 158                 165                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012   0.047008547008547  0.0470430107526882 
                274                 226                 109                  76 
 0.0471818958155423  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                170                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494505494505494 
                165                 223                  98                 165 
 0.0494997367035282  0.0496535796766744  0.0496568429551877  0.0497194815244728 
                106                  37                 137                 135 
 0.0502816607552681  0.0509113764927718  0.0511221945137157  0.0512921525370312 
                509                 224                 141                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526157299679707  0.0526235972095845 
                165                 285                 159                 204 
 0.0527306967984934   0.052766292577279  0.0529287585522802  0.0529417416647984 
                 78                 135                 158                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538535513119934 
                493                 131                 239                 278 
 0.0538555691554468  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                163                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0552183277853926 
                181                 239                 141                 375 
 0.0555828824397442  0.0556701030927835  0.0557219892150989  0.0568402950626782 
                283                  41                 129                 171 
 0.0569210866752911  0.0569312169312169  0.0571776155717762  0.0572625698324022 
                220                 124                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0579772385656002  0.0580472177728254   0.058057312988463  0.0590868397493286 
                184                 215                 454                 214 
 0.0594161801501251  0.0594954783436459  0.0601947477131897  0.0602798708288482 
                 74                 271                 127                  33 
 0.0602923264311815  0.0603881058119328  0.0604450348721355  0.0604914933837429 
                153                 145                 263                 160 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606119664782693 
                 27                 150                 216                 160 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0616624904673712 
                210                 220                 111                 316 
 0.0636079249217935  0.0636720453554296  0.0641271581255138  0.0643896976483763 
                341                 147                  88                 157 
 0.0645252183713722  0.0645476772616137  0.0646551724137931  0.0646766169154229 
                264                 248                 223                 116 
 0.0649717514124294  0.0651982378854626  0.0654566518632941  0.0655307994757536 
                333                  49                 179                 129 
  0.065705506972347  0.0657229524772497  0.0659246575342466   0.065989847715736 
                176                  37                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676125848241826  0.0676933491284481  0.0678240740740741 
                200                 155                 256                 376 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0682505399568035 
                 74                 189                 163                 183 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0703940720781408 
                107                 287                 243                 114 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0715539091440827 
                135                  76                 125                 283 
 0.0718046912398277  0.0718416370106761  0.0721442885771543  0.0722415428390768 
                175                 154                 359                 123 
 0.0728862973760933  0.0729649936735555  0.0729847494553377  0.0730528709494031 
                 37                  72                  26                  30 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0737867751395327 
                147                 227                 170                 332 
 0.0739031028851388  0.0739470173432438   0.073986308583465  0.0744658345673789 
                356                 206                 119                 130 
 0.0746185336806848   0.074849349825563  0.0753043119455333  0.0755026672137874 
                182                 127                 176                  72 
  0.075534556908353  0.0757384498863923  0.0757575757575758  0.0761194029850746 
                180                 329                  32                 162 
 0.0761608704099475  0.0761834556584725  0.0763305322128851              0.0765 
                206                 238                 147                 206 
 0.0767867139391678  0.0771307365985345  0.0772969491128418   0.077457264957265 
                404                 144                 275                 178 
 0.0775623268698061  0.0777167100568894   0.077766445690974   0.077792732166891 
                214                 355                 110                 292 
 0.0781227011917022  0.0792792792792793  0.0795259032689734  0.0795300497062811 
                243                 186                 408                 189 
 0.0795717592592593  0.0797656602073006  0.0799757649197213  0.0800351802990325 
                146                 245                 126                 151 
 0.0803679496489954  0.0806698903172544  0.0808438558669541   0.081692573402418 
                203                 390                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0845241304933944  0.0846036585365854  0.0850873264666368 
                171                 154                 125                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0872557726465364  0.0879211175020542  0.0880537203509152  0.0883005267535348 
                128                 110                 289                 310 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0918690601900739  0.0919729186043997  0.0920472328923033 
                224                 353                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0964261631827377 
                172                  80                 149                 181 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0984398216939079 
                195                 169                 295                  80 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102642276422764   0.102649006622517 
                269                 176                 111                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103325799160478 
                157                 134                 167                 105 
  0.103597052549932   0.105719237435009   0.105905511811024    0.10730054175318 
                139                 119                 345                 150 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.111923920994879   0.112025605852766   0.112173739788803   0.114229765013055 
                130                 202                 178                  73 
  0.114525835974502   0.114706592610481   0.115978211529732   0.116141117702154 
                198                 518                 102                 230 
  0.117099936431463   0.118951612903226   0.119464797706276   0.120465801097577 
                174                 142                 199                 328 
  0.121081745543946              0.1225   0.122544159230289   0.123858909955167 
                102                  73                  54                 269 
  0.124222197081118   0.125036689169357   0.125267338832875    0.12553251917069 
                406                 261                 175                 319 
  0.126307739369838   0.126770467101959   0.131510445635971   0.135149023638232 
                204                 378                 296                 234 
  0.136729555838747   0.145720649061406   0.145816826598586   0.146203845806626 
                383                  95                 388                 188 
    0.1463243873979   0.147475481293135   0.148916657113378   0.152476213710661 
                247                 121                 211                 112 
  0.152999645012425   0.153031761308951   0.154871196536584   0.155465949820789 
                104                 173                 210                 200 
   0.16151983045716   0.162202043132804   0.163961038961039   0.164057181756297 
                186                 454                 210                 196 
  0.167901234567901   0.172022950473442   0.181258488003622   0.182134570765661 
                167                 232                 190                 212 
  0.182632457871565   0.184947958366693   0.185637891520244   0.189697630293488 
                294                 211                 262                 218 
  0.198355345128333   0.203438395415473    0.20463712781353   0.205955334987593 
                243                 341                 276                 319 
  0.234804706537631    0.25564486542374   0.261106454316848   0.279759519038076 
                229                 237                 234                 219 

> ##########################
> 
> 
> #Extract average unemployment rate
> data$unemployment[data$cntry==cntry&data$essround==round]<-
+   Empl.country<-as.numeric(gsub(",", "",as.character(
+     factor(UE_rate$Value[UE_rate$GEO==country&UE_rate$TIME==year][1]
+            , exclude = 0))))

> ##########################
> 
> 
> #Mean unemployment risk by country
> data%>%
+   group_by(cntry,essround,occupation) %>%
+   summarise(meanRisk = mean(risk,na.rm=T))
# A tibble: 1,059 × 4
# Groups:   cntry, essround [98]
   cntry essround occupation                                         meanRisk
   <chr> <fct>    <chr>                                                 <dbl>
 1 AT    1        Armed forces occupations                           NaN     
 2 AT    1        Clerical support workers                             0.0233
 3 AT    1        Craft and related trades workers                     0.0427
 4 AT    1        Elementary occupations                               0.0516
 5 AT    1        Managers                                             0.0194
 6 AT    1        Plant and machine operators and assemblers           0.0470
 7 AT    1        Professionals                                      NaN     
 8 AT    1        Service and sales workers                            0.0423
 9 AT    1        Skilled agricultural, forestry and fishery workers NaN     
10 AT    1        Technicians and associate professionals              0.0140
# … with 1,049 more rows
# ℹ Use `print(n = ...)` to see more rows

> #Check
> table(data$risk[data$occupation=="Technicians and associate professionals"&
+                   data$cntry=="CH"&data$essround==4])

0.0174951994879454 
               463 

> ##########################
> #Save data
> ##########################
> 
> save(data,file="DataFile_05_Risk.Rda")

> ################
> #PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
> #
> #Observational Data
> #Part V: Recoding
> #
> #Verena Fetscher
> #July 2022
> ####################
> 
> rm(list=ls())

> ##########################
> #Load Data
> ##########################
> 
> load("DataFile_05_Risk.Rda")

> ##########################
> #Generate variables
> ##########################
> 
> data$single<-0

> data$single[(data$marital=="Never married"&data$chldhhe=="No")|
+               (data$maritala=="Never married and never in civil partnership"&
+                  data$chldhhe=="No")|
+               (data$maritalb=="None of these (NEVER married or in legally registered civil"&
+                  data$chldhhe=="No")]<-1

> table(data$single)

     0      1 
149372  42996 

> data$married67<-0

> data$married67[(data$marital=="Married"&data$chldhhe=="Yes")|
+                  (data$maritala=="Married"&data$chldhhe=="Yes")|
+                  (data$maritalb=="Legally married"&data$chldhhe=="Yes")]<-1

> table(data$married67)

     0      1 
156404  35964 

> ##########################
> #Import inequality measure
> ##########################
> 
> data$cntryName[data$cntry=="AT"]<-"Austria"

> data$cntryName[data$cntry=="BE"]<-"Belgium"

> data$cntryName[data$cntry=="CH"]<-"Switzerland"

> data$cntryName[data$cntry=="DE"]<-"Germany"

> data$cntryName[data$cntry=="DK"]<-"Denmark"

> data$cntryName[data$cntry=="ES"]<-"Spain"

> data$cntryName[data$cntry=="FI"]<-"Finland"

> data$cntryName[data$cntry=="FR"]<-"France"

> data$cntryName[data$cntry=="GB"]<-"United Kingdom"

> data$cntryName[data$cntry=="IE"]<-"Ireland"

> data$cntryName[data$cntry=="IT"]<-"Italy"

> data$cntryName[data$cntry=="NL"]<-"Netherlands"

> data$cntryName[data$cntry=="NO"]<-"Norway"

> data$cntryName[data$cntry=="PT"]<-"Portugal"

> data$cntryName[data$cntry=="SE"]<-"Sweden"

> data$year[data$essround==1]<-2002

> data$year[data$essround==2]<-2004

> data$year[data$essround==3]<-2006

> data$year[data$essround==4]<-2008

> data$year[data$essround==5]<-2010

> data$year[data$essround==6]<-2012

> data$year[data$essround==7]<-2014

> #Standardized World Income Inequality Database
> #https://dataverse.harvard.edu/dataset.xhtml?persistentId=hdl:1902.1/11992
> #February 2018
> load("swiid6_1.Rda")

> summary(swiid_summary$gini_disp)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  18.30   31.45   38.10   38.11   45.10   60.90 

> dnew<-data.frame(swiid_summary$gini_disp,swiid_summary$country,swiid_summary$year)

> dnew %>%
+   group_by(swiid_summary.country) %>% 
+   filter (! duplicated(swiid_summary.year))
# A tibble: 5,119 × 3
# Groups:   swiid_summary.country [192]
   swiid_summary.gini_disp swiid_summary.country swiid_summary.year
                     <dbl> <chr>                              <dbl>
 1                    33.3 Afghanistan                         2007
 2                    33.5 Afghanistan                         2008
 3                    33.8 Afghanistan                         2009
 4                    34   Afghanistan                         2010
 5                    34.2 Afghanistan                         2011
 6                    34.4 Afghanistan                         2012
 7                    37.9 Albania                             1996
 8                    38.1 Albania                             1997
 9                    38.3 Albania                             1998
10                    38.4 Albania                             1999
# … with 5,109 more rows
# ℹ Use `print(n = ...)` to see more rows

> names(dnew)<-c("gini.disp","country","year")

> dnew$cntryName<-as.character(dnew$country)

> dnew<-dnew[dnew$year==2002|dnew$year==2004|dnew$year==2006|dnew$year==2008|
+              dnew$year==2010|dnew$year==2012|dnew$year==2014,]

> table(data$cntryName)

       Austria        Belgium        Denmark        Finland         France        Germany 
          8713          12577          10836          14275          12981          20490 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
         15490           3696          13505          11703          13718          13543 
        Sweden    Switzerland United Kingdom 
         12839          12335          15667 

> table(dnew$cntryName)

                     Afghanistan                          Albania 
                               3                                6 
                         Algeria                           Angola 
                               5                                4 
                        Anguilla                        Argentina 
                               4                                7 
                         Armenia                        Australia 
                               7                                7 
                         Austria                       Azerbaijan 
                               7                                4 
                         Bahamas                       Bangladesh 
                               6                                5 
                        Barbados                          Belarus 
                               5                                7 
                         Belgium                           Belize 
                               7                                4 
                           Benin                           Bhutan 
                               7                                5 
                         Bolivia           Bosnia and Herzegovina 
                               7                                7 
                        Botswana                           Brazil 
                               5                                7 
                        Bulgaria                     Burkina Faso 
                               7                                7 
                         Burundi                       Cabo Verde 
                               6                                7 
                        Cambodia                         Cameroon 
                               6                                7 
                          Canada         Central African Republic 
                               7                                4 
                            Chad                            Chile 
                               4                                7 
                           China                         Colombia 
                               7                                7 
                         Comoros                            Congo 
                               5                                3 
                     Congo, D.R.                       Costa Rica 
                               5                                7 
                   Côte D'Ivoire                          Croatia 
                               7                                7 
                          Cyprus                   Czech Republic 
                               7                                7 
                         Denmark                         Djibouti 
                               7                                6 
                        Dominica               Dominican Republic 
                               5                                7 
                         Ecuador                            Egypt 
                               7                                7 
                     El Salvador                Equatorial Guinea 
                               7                                1 
                         Estonia                         Ethiopia 
                               7                                5 
                            Fiji                          Finland 
                               6                                7 
                          France                           Gambia 
                               7                                5 
                         Georgia                          Germany 
                               7                                7 
                           Ghana                           Greece 
                               6                                7 
                         Grenada                        Guatemala 
                               4                                7 
                          Guinea                    Guinea Bissau 
                               6                                5 
                          Guyana                            Haiti 
                               3                                6 
                        Honduras                        Hong Kong 
                               7                                7 
                         Hungary                          Iceland 
                               7                                7 
                           India                        Indonesia 
                               6                                7 
                            Iran                             Iraq 
                               7                                4 
                         Ireland                           Israel 
                               7                                7 
                           Italy                          Jamaica 
                               7                                2 
                           Japan                           Jordan 
                               7                                7 
                      Kazakhstan                            Kenya 
                               7                                3 
                        Kiribati                            Korea 
                               1                                7 
                          Kosovo                       Kyrgyzstan 
                               5                                7 
                             Lao                           Latvia 
                               6                                7 
                         Lebanon                          Lesotho 
                               6                                5 
                         Liberia                        Lithuania 
                               5                                7 
                      Luxembourg                        Macedonia 
                               7                                7 
                      Madagascar                           Malawi 
                               6                                6 
                        Malaysia                         Maldives 
                               7                                5 
                            Mali                            Malta 
                               4                                7 
                      Mauritania                        Mauritius 
                               7                                6 
                          Mexico                       Micronesia 
                               7                                6 
                         Moldova                         Mongolia 
                               7                                7 
                      Montenegro                          Morocco 
                               5                                7 
                      Mozambique                          Myanmar 
                               4                                3 
                         Namibia                            Nauru 
                               7                                1 
                           Nepal                      Netherlands 
                               5                                7 
                     New Zealand                        Nicaragua 
                               7                                7 
                           Niger                          Nigeria 
                               7                                5 
                          Norway                         Pakistan 
                               7                                6 
                           Palau                        Palestine 
                               1                                5 
                          Panama                 Papua New Guinea 
                               7                                4 
                        Paraguay                             Peru 
                               7                                7 
                     Philippines                           Poland 
                               7                                7 
                        Portugal                      Puerto Rico 
                               7                                7 
                           Qatar                          Romania 
                               6                                7 
                          Russia                           Rwanda 
                               7                                7 
           Saint Kitts and Nevis                      Saint Lucia 
                               4                                3 
Saint Vincent and the Grenadines                            Samoa 
                               4                                4 
           Sao Tome and Principe                          Senegal 
                               5                                5 
                          Serbia                       Seychelles 
                               7                                4 
                    Sierra Leone                        Singapore 
                               5                                7 
                        Slovakia                         Slovenia 
                               7                                7 
                 Solomon Islands                          Somalia 
                               4                                1 
                    South Africa                            Spain 
                               7                                7 
                       Sri Lanka                            Sudan 
                               6                                4 
                        Suriname                        Swaziland 
                               2                                4 
                          Sweden                      Switzerland 
                               7                                7 
                           Syria                           Taiwan 
                               3                                7 
                      Tajikistan                         Tanzania 
                               7                                7 
                        Thailand                      Timor-Leste 
                               6                                3 
                            Togo                            Tonga 
                               5                                4 
             Trinidad and Tobago                          Tunisia 
                               2                                6 
                          Turkey                     Turkmenistan 
                               7                                2 
                          Tuvalu                           Uganda 
                               5                                6 
                         Ukraine             United Arab Emirates 
                               7                                1 
                  United Kingdom                    United States 
                               7                                7 
                         Uruguay                       Uzbekistan 
                               7                                1 
                         Vanuatu                        Venezuela 
                               3                                7 
                        Viet Nam                            Yemen 
                               7                                7 
                          Zambia                         Zimbabwe 
                               7                                5 

> dnew<-dnew[(dnew$cntryName %in% data$cntryName),]

> data <- left_join(data,dnew)

> rm(dnew)

> rm(swiid)

> rm(swiid_summary)

> ##########################
> #Recode variables
> ##########################
> 
> 
> #Redistribution
> table(data$gincdif)

            Agree strongly                      Agree Neither agree nor disagree 
                     47292                      83182                      29103 
                  Disagree          Disagree strongly                    Refusal 
                     24320                       5007                          0 
                Don't know                  No answer 
                         0                          0 

> data$redistribution_num<-as.numeric(data$gincdif)

> data$redistribution_num[data$redistribution_num>5]<-NA

> table(data$redistribution_num)

    1     2     3     4     5 
47292 83182 29103 24320  5007 

> # Referse answer categories
> data$redistribution<-NA

> data$redistribution[data$redistribution_num==1]<-5

> data$redistribution[data$redistribution_num==2]<-4

> data$redistribution[data$redistribution_num==3]<-3

> data$redistribution[data$redistribution_num==4]<-2

> data$redistribution[data$redistribution_num==5]<-1

> table(data$redistribution)  

    1     2     3     4     5 
 5007 24320 29103 83182 47292 

> ##########################
> 
> 
> #Social identity
> #same culture and traditions important
> table(data$pplstrd)

            Agree strongly                      Agree Neither agree nor disagree 
                      6239                      17311                      14082 
                  Disagree          Disagree strongly                    Refusal 
                     14373                       3012                          0 
                Don't know                  No answer 
                         0                          0 

> data$identity<-NA

> data$identity[data$pplstrd=="Agree strongly"]<-5

> data$identity[data$pplstrd=="Agree"]<-4

> data$identity[data$pplstrd=="Neither agree nor disagree"]<-3

> data$identity[data$pplstrd=="Disagree"]<-2

> data$identity[data$pplstrd=="Disagree strongly"]<-1

> table(data$identity)

    1     2     3     4     5 
 3012 14373 14082 17311  6239 

> ##########################
> 
> 
> #Income to thousands
> data$income.PPP.th<-data$income.PPP/1000

> data$income.dist.th<-data$income_dist/1000

> summary(data$income.PPP[data$cntry=="FR"])
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's 
   981.5  16498.8  28807.1  32634.7  41115.4 190863.7     2698 

> ##########################
> 
> #Female
> data$gender<-NA

> data$gender[data$gndr=="Female"]<-1

> data$gender[data$gndr=="Male"]<-0

> table(data$gender)

     0      1 
 91302 100935 

> ##########################
> 
> 
> #Unemployment
> #Using this card, which of these descriptions applies to what you 
> #have been doing for the last 7 days?
> #Unemployed and actively looking for a job
> data$uempl<-NA

> data$uempl[data$uempla=="Marked"]<-1

> data$uempl[data$uempla=="Not marked"]<-0

> table(data$uempl)

     0      1 
184344   8024 

> ##########################
> 
> 
> #Standardize variables
> #range <- function(x){(x-min(x,na.rm=T))/(max(x,na.rm=T)-min(x,na.rm=T))}
> ##########################
> 
> 
> ##########################
> #Save data
> ##########################
> 
> save(data,file="DataFile_06_combined.Rda")

> ################
> #PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
> #
> #Observational Data
> #Part VI: Replacement Rates
> #
> #Verena Fetscher
> #July 2022
> ####################
> 
> rm(list=ls())

> ##########################
> #Load Data
> ##########################
> 
> load("DataFile_06_combined.Rda")

> load("Benefits.Rda")

> ##########################
> #Import replacement rate data
> ##########################
> 
> #https://stats.oecd.org/Index.aspx?DataSetCode=FIXINCLSA#
> #Accessed 11-2017
> 
> Ins_single<-read.csv("TaxBen_OECD_single.csv", header = TRUE, sep = ",", quote = "\"",
+                      dec = ".")

> names(Ins_single) <- c("COU","Country","FAM","Family.type","CHI","Number.of.children", 
+                        "ER1","First.earner","ER2","Second.earner","VAR","Variable", 
+                        "EMP","Employment.status","YEA","Year","Unit.Code","Unit",
+                        "PowerCode.Code","PowerCode","Reference.Period.Code",
+                        "Reference.Period","Value","Flag.Codes","Flags")

> Ins_married<-read.csv("TaxBen_OECD_married67.csv", header = TRUE, sep = ",", quote = "\"",
+                       dec = ".")

> names(Ins_married) <- c("COU","Country","FAM","Family.type","CHI","Number.of.children" ,
+                         "ER1","First.earner","ER2","Second.earner","VAR","Variable",
+                         "EMP","Employment.status","YEA","Year","Unit.Code","Unit",
+                         "PowerCode.Code","PowerCode","Reference.Period.Code",
+                         "Reference.Period","Value", "Flag.Codes","Flags" )

> ##########################
> #Extract indicators from data file for all countries
> ##########################
> 
> #single earner, no children
> single<-data.frame(Ins_single$Country[Ins_single$Employment.status=="Employed"&
+                                         Ins_single$Variable=="Gross Income"],
+                    Ins_single$First.earner[Ins_single$Employment.status=="Employed"&
+                                              Ins_single$Variable=="Gross Income"],
+                    Ins_single$Year[Ins_single$Employment.status=="Employed"&
+                                      Ins_single$Variable=="Gross Income"],
+                    Ins_single$Value[Ins_single$Employment.status=="Employed"&
+                                       Ins_single$Variable=="Gross Income"],
+                    Ins_single$Value[Ins_single$Employment.status=="Employed"&
+                                       Ins_single$Variable=="Net Income"],
+                    Ins_single$Value[Ins_single$Employment.status=="Employed"&
+                                       Ins_single$Variable=="Income Tax"],
+                    Ins_single$Value[Ins_single$Employment.status=="Unemployed"&
+                                       Ins_single$Variable=="Net Income"])

> names(single) <- c("Country","AW","Year","Gross","Net","Tax","Unemployment")

> single$AW<-as.numeric(gsub("% of AW", "", single$AW))

> #married, two children, spouse earns 67%
> married<-data.frame(Ins_married$Country[Ins_married$Employment.status=="Employed"&
+                                           Ins_married$Variable=="Gross Income"],
+                     Ins_married$First.earner[Ins_married$Employment.status=="Employed"&
+                                                Ins_married$Variable=="Gross Income"],
+                     Ins_married$Year[Ins_married$Employment.status=="Employed"&
+                                        Ins_married$Variable=="Gross Income"],
+                     Ins_married$Value[Ins_married$Employment.status=="Employed"&
+                                         Ins_married$Variable=="Gross Income"],
+                     Ins_married$Value[Ins_married$Employment.status=="Employed"&
+                                         Ins_married$Variable=="Net Income"],
+                     Ins_married$Value[Ins_married$Employment.status=="Employed"&
+                                         Ins_married$Variable=="Income Tax"],
+                     Ins_married$Value[Ins_married$Employment.status=="Unemployed"&
+                                         Ins_married$Variable=="Net Income"])

> names(married) <- c("Country","AW","Year","Gross","Net","Tax","Unemployment")

> married$AW<-as.numeric(gsub("% of AW", "", married$AW))

> ##########################
> 
> 
> #Remove full data file
> rm(Ins_married,Ins_single)

> #Generate replacement Rate
> single$RR<-single$Unemployment/single$Net

> married$RR<-married$Unemployment/married$Net

> single$famtype<-"single"

> married$famtype<-"married"

> replacement<-rbind(single,married)

> ##########################
> #Save data frame
> ##########################
> 
> #Replacement rates
> save(replacement,file="replacement.Rda")

> ##########################
> #Calculation for main data frame
> ##########################
> 
> #Replacement rate 200% AW
> 
> married %>%
+   group_by(Country,Year) %>%
+   filter(AW==200) %>%
+   summarize(marriedRR = mean(RR)) -> married200

> married200<-data.frame(married200)

> single %>%
+   group_by(Country,Year) %>%
+   filter(AW==200) %>%
+   summarize(singleRR = mean(RR)) -> single200

> single200<-data.frame(single200)

> combined200<-cbind(single200,married200$marriedRR)

> names(combined200)[names(combined200) == "married200$marriedRR"] <- 
+   "marriedRR"

> combined200$RR<-(combined200$singleRR+combined200$marriedRR)/2

> rm(married200,single200)

> #Replacement rate 100% AW
> married %>%
+   group_by(Country,Year) %>%
+   filter(AW==100) %>%
+   summarize(marriedRR = mean(RR)) -> marriedAW

> marriedAW<-data.frame(marriedAW)

> single %>%
+   group_by(Country,Year) %>%
+   filter(AW==100) %>%
+   summarize(singleRR = mean(RR)) -> singleAW

> singleAW<-data.frame(singleAW)

> combinedAW<-cbind(singleAW,marriedAW$marriedRR)

> names(combinedAW)[names(combinedAW) == "marriedAW$marriedRR"] <- 
+   "marriedRR"

> combinedAW$RR<-(combinedAW$singleRR+combinedAW$marriedRR)/2

> rm(singleAW,marriedAW)

> ##########################
> #Add to data frame
> ##########################
> 
> data$benLev[data$cntry=="AT"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Austria"]

> data$benLev[data$cntry=="AT"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Austria"]

> data$benLev[data$cntry=="AT"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Austria"]

> data$benLev[data$cntry=="AT"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Austria"]

> data$benLev[data$cntry=="AT"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Austria"]

> data$benLev[data$cntry=="AT"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Austria"]

> data$benLev[data$cntry=="AT"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Austria"]

> data$benLevAW[data$cntry=="AT"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Austria"]

> data$benLevAW[data$cntry=="AT"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Austria"]

> data$benLevAW[data$cntry=="AT"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Austria"]

> data$benLevAW[data$cntry=="AT"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Austria"]

> data$benLevAW[data$cntry=="AT"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Austria"]

> data$benLevAW[data$cntry=="AT"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Austria"]

> data$benLevAW[data$cntry=="AT"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Austria"]

> data$benLev[data$cntry=="BE"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Belgium"]

> data$benLev[data$cntry=="BE"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Belgium"]

> data$benLev[data$cntry=="BE"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Belgium"]

> data$benLev[data$cntry=="BE"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Belgium"]

> data$benLev[data$cntry=="BE"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Belgium"]

> data$benLev[data$cntry=="BE"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Belgium"]

> data$benLev[data$cntry=="BE"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Belgium"]

> data$benLevAW[data$cntry=="BE"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Belgium"]

> data$benLevAW[data$cntry=="BE"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Belgium"]

> data$benLevAW[data$cntry=="BE"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Belgium"]

> data$benLevAW[data$cntry=="BE"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Belgium"]

> data$benLevAW[data$cntry=="BE"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Belgium"]

> data$benLevAW[data$cntry=="BE"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Belgium"]

> data$benLevAW[data$cntry=="BE"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Belgium"]

> data$benLev[data$cntry=="DK"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Denmark"]

> data$benLev[data$cntry=="DK"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Denmark"]

> data$benLev[data$cntry=="DK"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Denmark"]

> data$benLev[data$cntry=="DK"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Denmark"]

> data$benLev[data$cntry=="DK"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Denmark"]

> data$benLev[data$cntry=="DK"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Denmark"]

> data$benLev[data$cntry=="DK"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Denmark"]

> data$benLevAW[data$cntry=="DK"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Denmark"]

> data$benLevAW[data$cntry=="DK"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Denmark"]

> data$benLevAW[data$cntry=="DK"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Denmark"]

> data$benLevAW[data$cntry=="DK"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Denmark"]

> data$benLevAW[data$cntry=="DK"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Denmark"]

> data$benLevAW[data$cntry=="DK"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Denmark"]

> data$benLevAW[data$cntry=="DK"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Denmark"]

> data$benLev[data$cntry=="FI"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Finland"]

> data$benLev[data$cntry=="FI"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Finland"]

> data$benLev[data$cntry=="FI"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Finland"]

> data$benLev[data$cntry=="FI"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Finland"]

> data$benLev[data$cntry=="FI"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Finland"]

> data$benLev[data$cntry=="FI"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Finland"]

> data$benLev[data$cntry=="FI"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Finland"]

> data$benLevAW[data$cntry=="FI"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Finland"]

> data$benLevAW[data$cntry=="FI"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Finland"]

> data$benLevAW[data$cntry=="FI"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Finland"]

> data$benLevAW[data$cntry=="FI"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Finland"]

> data$benLevAW[data$cntry=="FI"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Finland"]

> data$benLevAW[data$cntry=="FI"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Finland"]

> data$benLevAW[data$cntry=="FI"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Finland"]

> data$benLev[data$cntry=="FR"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="France"]

> data$benLev[data$cntry=="FR"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="France"]

> data$benLev[data$cntry=="FR"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="France"]

> data$benLev[data$cntry=="FR"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="France"]

> data$benLev[data$cntry=="FR"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="France"]

> data$benLev[data$cntry=="FR"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="France"]

> data$benLev[data$cntry=="FR"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="France"]

> data$benLevAW[data$cntry=="FR"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="France"]

> data$benLevAW[data$cntry=="FR"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="France"]

> data$benLevAW[data$cntry=="FR"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="France"]

> data$benLevAW[data$cntry=="FR"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="France"]

> data$benLevAW[data$cntry=="FR"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="France"]

> data$benLevAW[data$cntry=="FR"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="France"]

> data$benLevAW[data$cntry=="FR"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="France"]

> data$benLev[data$cntry=="DE"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Germany"]

> data$benLev[data$cntry=="DE"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Germany"]

> data$benLev[data$cntry=="DE"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Germany"]

> data$benLev[data$cntry=="DE"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Germany"]

> data$benLev[data$cntry=="DE"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Germany"]

> data$benLev[data$cntry=="DE"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Germany"]

> data$benLev[data$cntry=="DE"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Germany"]

> data$benLevAW[data$cntry=="DE"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Germany"]

> data$benLevAW[data$cntry=="DE"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Germany"]

> data$benLevAW[data$cntry=="DE"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Germany"]

> data$benLevAW[data$cntry=="DE"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Germany"]

> data$benLevAW[data$cntry=="DE"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Germany"]

> data$benLevAW[data$cntry=="DE"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Germany"]

> data$benLevAW[data$cntry=="DE"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Germany"]

> data$benLev[data$cntry=="IE"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Ireland"]

> data$benLev[data$cntry=="IE"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Ireland"]

> data$benLev[data$cntry=="IE"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Ireland"]

> data$benLev[data$cntry=="IE"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Ireland"]

> data$benLev[data$cntry=="IE"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Ireland"]

> data$benLev[data$cntry=="IE"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Ireland"]

> data$benLev[data$cntry=="IE"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Ireland"]

> data$benLevAW[data$cntry=="IE"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Ireland"]

> data$benLevAW[data$cntry=="IE"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Ireland"]

> data$benLevAW[data$cntry=="IE"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Ireland"]

> data$benLevAW[data$cntry=="IE"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Ireland"]

> data$benLevAW[data$cntry=="IE"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Ireland"]

> data$benLevAW[data$cntry=="IE"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Ireland"]

> data$benLevAW[data$cntry=="IE"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Ireland"]

> data$benLev[data$cntry=="IT"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Italy"]

> data$benLev[data$cntry=="IT"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Italy"]

> data$benLev[data$cntry=="IT"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Italy"]

> data$benLev[data$cntry=="IT"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Italy"]

> data$benLev[data$cntry=="IT"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Italy"]

> data$benLev[data$cntry=="IT"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Italy"]

> data$benLev[data$cntry=="IT"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Italy"]

> data$benLevAW[data$cntry=="IT"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Italy"]

> data$benLevAW[data$cntry=="IT"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Italy"]

> data$benLevAW[data$cntry=="IT"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Italy"]

> data$benLevAW[data$cntry=="IT"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Italy"]

> data$benLevAW[data$cntry=="IT"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Italy"]

> data$benLevAW[data$cntry=="IT"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Italy"]

> data$benLevAW[data$cntry=="IT"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Italy"]

> data$benLev[data$cntry=="NL"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Netherlands"]

> data$benLev[data$cntry=="NL"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Netherlands"]

> data$benLev[data$cntry=="NL"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Netherlands"]

> data$benLev[data$cntry=="NL"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Netherlands"]

> data$benLev[data$cntry=="NL"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Netherlands"]

> data$benLev[data$cntry=="NL"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Netherlands"]

> data$benLev[data$cntry=="NL"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Netherlands"]

> data$benLevAW[data$cntry=="NL"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Netherlands"]

> data$benLevAW[data$cntry=="NL"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Netherlands"]

> data$benLevAW[data$cntry=="NL"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Netherlands"]

> data$benLevAW[data$cntry=="NL"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Netherlands"]

> data$benLevAW[data$cntry=="NL"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Netherlands"]

> data$benLevAW[data$cntry=="NL"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Netherlands"]

> data$benLevAW[data$cntry=="NL"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Netherlands"]

> data$benLev[data$cntry=="NO"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Norway"]

> data$benLev[data$cntry=="NO"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Norway"]

> data$benLev[data$cntry=="NO"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Norway"]

> data$benLev[data$cntry=="NO"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Norway"]

> data$benLev[data$cntry=="NO"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Norway"]

> data$benLev[data$cntry=="NO"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Norway"]

> data$benLev[data$cntry=="NO"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Norway"]

> data$benLevAW[data$cntry=="NO"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Norway"]

> data$benLevAW[data$cntry=="NO"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Norway"]

> data$benLevAW[data$cntry=="NO"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Norway"]

> data$benLevAW[data$cntry=="NO"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Norway"]

> data$benLevAW[data$cntry=="NO"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Norway"]

> data$benLevAW[data$cntry=="NO"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Norway"]

> data$benLevAW[data$cntry=="NO"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Norway"]

> data$benLev[data$cntry=="PT"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Portugal"]

> data$benLev[data$cntry=="PT"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Portugal"]

> data$benLev[data$cntry=="PT"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Portugal"]

> data$benLev[data$cntry=="PT"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Portugal"]

> data$benLev[data$cntry=="PT"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Portugal"]

> data$benLev[data$cntry=="PT"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Portugal"]

> data$benLev[data$cntry=="PT"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Portugal"]

> data$benLevAW[data$cntry=="PT"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Portugal"]

> data$benLevAW[data$cntry=="PT"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Portugal"]

> data$benLevAW[data$cntry=="PT"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Portugal"]

> data$benLevAW[data$cntry=="PT"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Portugal"]

> data$benLevAW[data$cntry=="PT"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Portugal"]

> data$benLevAW[data$cntry=="PT"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Portugal"]

> data$benLevAW[data$cntry=="PT"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Portugal"]

> data$benLev[data$cntry=="ES"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Spain"]

> data$benLev[data$cntry=="ES"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Spain"]

> data$benLev[data$cntry=="ES"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Spain"]

> data$benLev[data$cntry=="ES"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Spain"]

> data$benLev[data$cntry=="ES"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Spain"]

> data$benLev[data$cntry=="ES"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Spain"]

> data$benLev[data$cntry=="ES"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Spain"]

> data$benLevAW[data$cntry=="ES"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Spain"]

> data$benLevAW[data$cntry=="ES"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Spain"]

> data$benLevAW[data$cntry=="ES"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Spain"]

> data$benLevAW[data$cntry=="ES"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Spain"]

> data$benLevAW[data$cntry=="ES"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Spain"]

> data$benLevAW[data$cntry=="ES"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Spain"]

> data$benLevAW[data$cntry=="ES"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Spain"]

> data$benLev[data$cntry=="SE"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Sweden"]

> data$benLev[data$cntry=="SE"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Sweden"]

> data$benLev[data$cntry=="SE"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Sweden"]

> data$benLev[data$cntry=="SE"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Sweden"]

> data$benLev[data$cntry=="SE"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Sweden"]

> data$benLev[data$cntry=="SE"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Sweden"]

> data$benLev[data$cntry=="SE"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Sweden"]

> data$benLevAW[data$cntry=="SE"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Sweden"]

> data$benLevAW[data$cntry=="SE"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Sweden"]

> data$benLevAW[data$cntry=="SE"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Sweden"]

> data$benLevAW[data$cntry=="SE"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Sweden"]

> data$benLevAW[data$cntry=="SE"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Sweden"]

> data$benLevAW[data$cntry=="SE"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Sweden"]

> data$benLevAW[data$cntry=="SE"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Sweden"]

> data$benLev[data$cntry=="CH"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="Switzerland"]

> data$benLev[data$cntry=="CH"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="Switzerland"]

> data$benLev[data$cntry=="CH"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="Switzerland"]

> data$benLev[data$cntry=="CH"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="Switzerland"]

> data$benLev[data$cntry=="CH"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="Switzerland"]

> data$benLev[data$cntry=="CH"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="Switzerland"]

> data$benLev[data$cntry=="CH"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="Switzerland"]

> data$benLevAW[data$cntry=="CH"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="Switzerland"]

> data$benLevAW[data$cntry=="CH"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="Switzerland"]

> data$benLevAW[data$cntry=="CH"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="Switzerland"]

> data$benLevAW[data$cntry=="CH"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="Switzerland"]

> data$benLevAW[data$cntry=="CH"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="Switzerland"]

> data$benLevAW[data$cntry=="CH"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="Switzerland"]

> data$benLevAW[data$cntry=="CH"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="Switzerland"]

> data$benLev[data$cntry=="GB"&data$essround==1]<-
+   combined200$RR[combined200$Year==2002&combined200$Country=="United Kingdom"]

> data$benLev[data$cntry=="GB"&data$essround==2]<-
+   combined200$RR[combined200$Year==2004&combined200$Country=="United Kingdom"]

> data$benLev[data$cntry=="GB"&data$essround==3]<-
+   combined200$RR[combined200$Year==2006&combined200$Country=="United Kingdom"]

> data$benLev[data$cntry=="GB"&data$essround==4]<-
+   combined200$RR[combined200$Year==2008&combined200$Country=="United Kingdom"]

> data$benLev[data$cntry=="GB"&data$essround==5]<-
+   combined200$RR[combined200$Year==2010&combined200$Country=="United Kingdom"]

> data$benLev[data$cntry=="GB"&data$essround==6]<-
+   combined200$RR[combined200$Year==2012&combined200$Country=="United Kingdom"]

> data$benLev[data$cntry=="GB"&data$essround==7]<-
+   combined200$RR[combined200$Year==2014&combined200$Country=="United Kingdom"]

> data$benLevAW[data$cntry=="GB"&data$essround==1]<-
+   combinedAW$RR[combinedAW$Year==2002&combinedAW$Country=="United Kingdom"]

> data$benLevAW[data$cntry=="GB"&data$essround==2]<-
+   combinedAW$RR[combinedAW$Year==2004&combinedAW$Country=="United Kingdom"]

> data$benLevAW[data$cntry=="GB"&data$essround==3]<-
+   combinedAW$RR[combinedAW$Year==2006&combinedAW$Country=="United Kingdom"]

> data$benLevAW[data$cntry=="GB"&data$essround==4]<-
+   combinedAW$RR[combinedAW$Year==2008&combinedAW$Country=="United Kingdom"]

> data$benLevAW[data$cntry=="GB"&data$essround==5]<-
+   combinedAW$RR[combinedAW$Year==2010&combinedAW$Country=="United Kingdom"]

> data$benLevAW[data$cntry=="GB"&data$essround==6]<-
+   combinedAW$RR[combinedAW$Year==2012&combinedAW$Country=="United Kingdom"]

> data$benLevAW[data$cntry=="GB"&data$essround==7]<-
+   combinedAW$RR[combinedAW$Year==2014&combinedAW$Country=="United Kingdom"]

> ##########################
> #Save data frame
> ##########################
> 
> #Combine ESS with replacement rate
> save(data,file="DataFile_07_Replacement.Rda")

> ################
> #PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
> #
> #Observational Data
> #Part VII: Occupational unemployment rates
> #
> #Verena Fetscher
> #July 2022
> ####################
> 
> rm(list=ls())

> ##########################
> #Load Data
> ##########################
> 
> our<-read.table("cntry_isco2d_our",header=T)

> names(our)<-c("cntry","isco2d","our")

> load("DataFile_07_Replacement.Rda")

> table(data$risk)

0.00101082173861339 0.00161404867970818 0.00176503033645891 0.00274330502939255 
                326                 293                 270                 110 
0.00286267575987202 0.00317042531554705 0.00336376741950985  0.0035218562253988 
                236                 355                 246                  55 
 0.0036231884057971 0.00421523730224813 0.00435471100554236 0.00448895027624309 
                326                 311                 152                 366 
0.00459066564651875 0.00490244627116965 0.00498367417081973 0.00522193211488251 
                194                 359                 193                 258 
0.00578130161876445 0.00587199060481503 0.00594273365748244 0.00623755806237558 
                287                 131                 112                 367 
 0.0065345080763583 0.00696748506967485 0.00704322607374672   0.007119524248262 
                301                 206                 113                 208 
0.00724125750618156 0.00773480662983425  0.0077958894401134 0.00793650793650794 
                211                 167                  49                  41 
0.00818245125348189 0.00824175824175824 0.00832376578645235 0.00844155844155844 
                106                 275                 264                  54 
0.00845335003130871 0.00846023688663283 0.00847457627118644 0.00874488832966342 
                311                 123                  64                 269 
0.00897654011461318 0.00921172575924771 0.00921675385217608 0.00923076923076923 
                242                 272                 401                 202 
0.00925272484905513 0.00947762838880317 0.00959473005871402  0.0096013554854803 
                312                  62                 179                 307 
0.00965107646622123 0.00992145514675486  0.0100413467217956  0.0103092783505155 
                179                 167                 160                   2 
 0.0103676377051266  0.0104117368670137  0.0105202478743335  0.0105263157894737 
                315                 439                 120                  78 
 0.0105684383336754  0.0108158220024722   0.010862365876275  0.0111783249552697 
                213                 206                 145                 444 
 0.0114810562571757  0.0116639598405433  0.0118375774260151  0.0118885448916409 
                216                 365                 120                 226 
 0.0119585886330023  0.0120654984199943  0.0121436389221869  0.0125066056015501 
                 97                  81                 127                  85 
 0.0127263614373815  0.0128509045539613  0.0130247850278199   0.013088276246171 
                276                 411                 225                  23 
 0.0132057674167902  0.0133810487007935  0.0134591854570879  0.0135111727005023 
                171                 255                 121                 293 
 0.0135225216646034  0.0139675349188373  0.0140120610145442   0.014044436416185 
                298                 227                 469                 146 
 0.0142175009388916  0.0143145007984184  0.0143663767587997  0.0146315889810314 
                262                 436                 317                 487 
 0.0147458840372226  0.0150669642857143    0.01517663563321  0.0152375935889236 
                127                  92                 226                 174 
  0.015375854214123  0.0154054184575264   0.015446694767143    0.01551306498995 
                 40                 132                 264                 260 
 0.0157491098329225  0.0158163905185268  0.0159854503685268  0.0161589895988113 
                 33                 390                  35                 325 
 0.0162093171665603  0.0162519045200609  0.0163213683449771  0.0163260512097721 
                199                  23                 467                 261 
 0.0164196123147092  0.0164333536214242  0.0164978360593875  0.0165365653245686 
                226                  56                 544                 338 
 0.0165680473372781   0.016656038770565  0.0166853053008276  0.0166950069562529 
                215                 207                 151                 283 
 0.0167084377610693  0.0167711021009952    0.01692628480314  0.0172651069685975 
                110                 366                 262                 273 
 0.0172672341551625  0.0172739541160594  0.0174939864421605  0.0174951994879454 
                316                 230                 536                 463 
 0.0175423941191212  0.0176535490989334  0.0176991150442478  0.0177547118273696 
                252                 125                 194                 164 
 0.0178211163416274  0.0178593575592211  0.0178794178794179  0.0180489901160292 
                119                 227                 253                 370 
 0.0180560891279293  0.0180937818552497  0.0181434599156118  0.0181750741839763 
                195                 156                 278                 108 
 0.0182452374563992  0.0182575272261371  0.0186451971127152  0.0186999343401182 
                211                  17                 587                 148 
 0.0188848920863309  0.0191923230707717  0.0194376952447067  0.0194924196145943 
                242                  77                 154                 206 
 0.0196571428571429  0.0197222222222222   0.019878902830464  0.0198854061341422 
                283                 296                 195                 159 
 0.0199234423280911  0.0199362041467305  0.0199433304272014  0.0200785994998214 
                511                 173                 351                 248 
 0.0201068974293713  0.0205553552109629  0.0206237424547284   0.020628078817734 
                259                 344                 141                 328 
 0.0206629358588033  0.0207115701072462  0.0207501167194065  0.0208122398470019 
                 88                 150                 263                 172 
   0.02081526452732  0.0208385638965604   0.020919175911252  0.0209403397866456 
                113                 180                 151                 190 
 0.0210041364278107  0.0211323866711337  0.0211568322981366  0.0211693548387097 
                339                 326                 394                   9 
 0.0211998923863331  0.0212652844231792  0.0214106769286397  0.0215326155794807 
                 56                 162                 230                 124 
 0.0215746707761278  0.0216911764705882  0.0217065004041104  0.0217617659308621 
                 28                   4                 450                 247 
 0.0217782577393808  0.0217859707924348  0.0217929668152551  0.0219236493825174 
                273                 291                 174                 145 
 0.0219341974077767  0.0220403022670025  0.0220897615708275  0.0222703371481596 
                 52                  83                 377                  20 
 0.0223612146352529  0.0224536670362744  0.0225645183083367  0.0226244343891403 
                119                 109                 548                   3 
 0.0227412415488629  0.0230348401957961  0.0230552952202437  0.0230622919638611 
                 90                 281                 356                 127 
 0.0231803430690774  0.0232148695892754   0.023341049382716  0.0233871878883742 
                199                 244                 439                  76 
 0.0234526191491455  0.0234632323008031  0.0235011990407674  0.0235447283640055 
                222                 136                 209                 337 
 0.0236710130391174  0.0237315875613748  0.0237923576063446  0.0238816610229906 
                216                 266                 475                  68 
 0.0239011309315612  0.0239206534422404  0.0241159646385855  0.0241173545499751 
                227                 163                 123                 352 
 0.0242544731610338  0.0243264977885002  0.0243547800799709  0.0244668911335578 
                 61                 307                 139                 154 
 0.0244889267461669  0.0245016611295681  0.0245203969128997   0.024554269627776 
                150                 121                 317                 443 
 0.0246305418719212  0.0247417579018989   0.024763619990995  0.0247737017627442 
                109                 340                  86                 115 
 0.0248179120582681  0.0249746878164023  0.0251256281407035  0.0251697962445066 
                268                 166                 129                 153 
 0.0251836306400839  0.0251931417728382  0.0253712871287129  0.0253881661770877 
                144                 405                 297                 203 
  0.025439388079584  0.0254668930390492  0.0254880694143167  0.0255052935514918 
                323                 134                 179                 264 
 0.0255974508762613  0.0256829707181417  0.0257529463116543  0.0257910706545297 
                340                 187                 181                 259 
 0.0259743135518158   0.026079869600652  0.0261760937213985  0.0262657244913807 
                176                 213                 306                 371 
 0.0263574064312072  0.0264531848242255  0.0264725347452019  0.0265044174029005 
                 46                 166                 156                 409 
 0.0266179390521136  0.0266429840142096  0.0266724967205947  0.0267139027192646 
                231                 191                 198                 260 
 0.0269498482955559  0.0269736842105263  0.0270528760759667  0.0270745772651745 
                175                 200                 243                 210 
 0.0272490757223059            0.027375  0.0273822562979189  0.0274423215573179 
                394                  86                 266                 144 
 0.0274626865671642  0.0274893097128894  0.0275103163686382  0.0275999116802826 
                113                  54                 398                 320 
 0.0277726199633943  0.0279437271150511   0.027964785085448  0.0282313475062647 
                316                 234                  65                 337 
  0.028270509977827  0.0285470085470085  0.0286692340607617  0.0287486347324076 
                 65                 289                 290                 181 
  0.028899183763512  0.0290282520956225  0.0291580880307162  0.0292200966996006 
                135                  61                 120                 174 
 0.0292865871644684   0.029377657518361  0.0295295295295295  0.0295730980205104 
                331                  95                 122                 247 
 0.0298372513562387  0.0298965967272362  0.0299936183790683  0.0299939283545841 
                176                 390                 326                 228 
 0.0300218340611354  0.0300982800982801   0.030188679245283  0.0301942222947609 
                366                 375                 245                 169 
 0.0302686770207459  0.0302711239799947   0.030411877394636  0.0307638727652658 
                317                 111                 266                  22 
 0.0308211473565804  0.0308783642812435  0.0312345066931086  0.0312998649809746 
                114                 189                 168                 351 
  0.031352533722202   0.031377415351888  0.0314051164566628  0.0315893385982231 
                157                 254                 250                  97 
 0.0316351953842119  0.0316678395496129  0.0317272248551869  0.0319337016574586 
                229                 230                 135                 332 
 0.0320326150262085  0.0320470415288497  0.0320665083135392  0.0322131636508252 
                 56                  66                  58                 150 
 0.0323421107482804  0.0325513638418647  0.0325693606755127  0.0326602346996686 
                421                 181                 166                 339 
 0.0326864147088866  0.0327533265097236  0.0331766657450926  0.0332120109190173 
                 99                  13                 139                 353 
 0.0333333333333333  0.0339471376675435  0.0339709257842387   0.034034034034034 
                142                 299                 122                 163 
 0.0340782122905028  0.0340900491865305  0.0343403607911324  0.0344104070499371 
                 90                 421                 235                 183 
 0.0345168698109875  0.0345318618725525  0.0346032855644879  0.0346285714285714 
                180                 135                  25                 281 
 0.0346534653465347  0.0347459003084916  0.0348244147157191  0.0348890414092885 
                 25                 203                 152                 205 
 0.0349115972430327  0.0350253807106599  0.0350921393607832  0.0351497282512167 
                291                  53                 160                 406 
 0.0351973182995581  0.0353383458646617  0.0353873479983604    0.03547209181012 
                349                 267                  69                  45 
 0.0354838709677419  0.0356401384083045  0.0356612184249629   0.035694612757519 
                176                 132                  76                 303 
 0.0359856057576969   0.036105476673428  0.0361134995700774  0.0362391785786189 
                242                 363                  70                 223 
 0.0362541993281075  0.0363489499192246  0.0365088419851683  0.0365853658536585 
                183                 123                 169                 179 
  0.036608183005613  0.0366379310344828  0.0367789392179636  0.0367839431449881 
                188                 119                 148                 168 
 0.0368731563421829  0.0369127516778524  0.0369810052109598  0.0369817341324224 
                 34                  26                 198                 313 
 0.0370029389894126  0.0370756402620608  0.0371853546910755  0.0373638098364692 
                167                  97                 133                 334 
 0.0373705538045925  0.0375362566114997  0.0376263384369058  0.0378919022889017 
                 13                 260                 295                 114 
 0.0379829731499673  0.0381717729784028  0.0382165605095541  0.0382320029839612 
                129                  89                   9                 123 
 0.0382728164867517  0.0383953168044077  0.0384615384615385  0.0385852090032154 
                 39                 231                 348                 147 
 0.0386931402066889   0.038787023977433  0.0388998035363458  0.0389047933641635 
                178                 413                 201                 155 
 0.0389174319349488  0.0391606080634501  0.0392809587217044  0.0395238095238095 
                158                 237                 232                 147 
 0.0401267159450898  0.0402792897631292  0.0403430749682338  0.0406144781144781 
                121                 213                 185                 194 
 0.0408432147562582    0.04099560761347  0.0411866985437948  0.0412392825206459 
                  9                 104                  56                 120 
 0.0412587412587413  0.0412642669007902  0.0412852723944195  0.0412961567445365 
                276                 198                 235                 298 
 0.0413082980012114  0.0415162454873646  0.0415865384615385  0.0416666666666667 
                373                 368                 319                 153 
 0.0416754367501579    0.04203013481364  0.0421978021978022  0.0422836752899197 
                233                 384                 242                 292 
 0.0423121387283237  0.0425136916364987  0.0425763261129115  0.0426995042379658 
                187                  95                 335                 197 
 0.0431328036322361  0.0431638211196045  0.0432341381246491  0.0433547898523287 
                123                 221                 135                 312 
 0.0433574207893274  0.0434476279943636  0.0434699883302045  0.0435029049171036 
                209                 352                 515                 177 
 0.0435547734271887  0.0435933286727255  0.0436484634957917  0.0437311002558735 
                176                  83                 227                 225 
 0.0438813349814586  0.0439361466262656  0.0441482715535194  0.0442073170731707 
                239                 181                 137                  90 
 0.0443974630021142   0.044525215810995  0.0445749030296677  0.0448607345329061 
                125                 226                 328                 322 
 0.0449438202247191  0.0451125472198807  0.0452668098463572  0.0453118266330111 
                 27                 311                  54                 310 
 0.0453752181500873  0.0454081632653061  0.0454236366109071  0.0454771657160357 
                186                 158                 165                 193 
 0.0458015267175573  0.0458288578589331  0.0461725394896719  0.0462850182704019 
                 53                 427                 125                 102 
 0.0463034418891804  0.0463450600379187  0.0467409948542024  0.0467555821969129 
                 74                 161                 221                 221 
 0.0467714393215826  0.0468945766959012   0.047008547008547  0.0470430107526882 
                274                 226                 109                  76 
 0.0471818958155423  0.0472636815920398  0.0473098330241187  0.0473145307359627 
                170                 155                 127                 358 
  0.047542735042735  0.0475452196382429  0.0477157360406091  0.0479256080114449 
                302                  62                  64                 140 
  0.047961145401194  0.0482120051085568  0.0482456140350877  0.0483870967741935 
                205                 149                  35                 132 
 0.0485338331185819  0.0487106017191977  0.0492055356227576  0.0494505494505494 
                165                 223                  98                 165 
 0.0494997367035282  0.0496535796766744  0.0496568429551877  0.0497194815244728 
                106                  37                 137                 135 
 0.0502816607552681  0.0509113764927718  0.0511221945137157  0.0512921525370312 
                509                 224                 141                 194 
 0.0513173417223751  0.0513616687062777  0.0516417910447761  0.0518164504653419 
                410                 343                 154                 253 
 0.0519694944571114   0.052053981907163  0.0522055664835289  0.0522119900389417 
                147                 167                 260                 394 
 0.0522693757168606  0.0524006824274921  0.0526157299679707  0.0526235972095845 
                165                 285                 159                 204 
 0.0527306967984934   0.052766292577279  0.0529287585522802  0.0529417416647984 
                 78                 135                 158                 305 
  0.053186119873817  0.0538116591928251   0.053840499816244  0.0538535513119934 
                493                 131                 239                 278 
 0.0538555691554468  0.0541211987798358  0.0541623127830024  0.0542635658914729 
                163                 227                 225                 149 
 0.0543535007831081  0.0551325007614986  0.0551415797317437  0.0552183277853926 
                181                 239                 141                 375 
 0.0555828824397442  0.0556701030927835  0.0557219892150989  0.0568402950626782 
                283                  41                 129                 171 
 0.0569210866752911  0.0569312169312169  0.0571776155717762  0.0572625698324022 
                220                 124                 143                 208 
 0.0574494949494949  0.0577124691399777  0.0579365729738589  0.0579766536964981 
                157                 443                 327                 225 
 0.0579772385656002  0.0580472177728254   0.058057312988463  0.0590868397493286 
                184                 215                 454                 214 
 0.0594161801501251  0.0594954783436459  0.0601947477131897  0.0602798708288482 
                 74                 271                 127                  33 
 0.0602923264311815  0.0603881058119328  0.0604450348721355  0.0604914933837429 
                153                 145                 263                 160 
 0.0605700712589074  0.0605714285714286  0.0605864166749776  0.0606119664782693 
                 27                 150                 216                 160 
 0.0606246548444499  0.0610859728506787   0.061569416498994  0.0616624904673712 
                210                 220                 111                 316 
 0.0636079249217935  0.0636720453554296  0.0641271581255138  0.0643896976483763 
                341                 147                  88                 157 
 0.0645252183713722  0.0645476772616137  0.0646551724137931  0.0646766169154229 
                264                 248                 223                 116 
 0.0649717514124294  0.0651982378854626  0.0654566518632941  0.0655307994757536 
                333                  49                 179                 129 
  0.065705506972347  0.0657229524772497  0.0659246575342466   0.065989847715736 
                176                  37                 214                 104 
 0.0662208091218068  0.0663316582914573   0.066402490801019  0.0664614270191959 
                154                  50                 108                 140 
 0.0668523676880223  0.0676125848241826  0.0676933491284481  0.0678240740740741 
                200                 155                 256                 376 
  0.067850348763475   0.068041136618414  0.0681222707423581  0.0682505399568035 
                 74                 189                 163                 183 
 0.0683411214953271  0.0686325439266616  0.0691271525139389  0.0691703391454302 
                282                 224                 160                 148 
  0.069882777276826  0.0701461377870564  0.0702966470190357  0.0703940720781408 
                107                 287                 243                 114 
 0.0704392560348239  0.0705556460811471  0.0710715061943056  0.0715539091440827 
                135                  76                 125                 283 
 0.0718046912398277  0.0718416370106761  0.0721442885771543  0.0722415428390768 
                175                 154                 359                 123 
 0.0728862973760933  0.0729649936735555  0.0729847494553377  0.0730528709494031 
                 37                  72                  26                  30 
 0.0731810490693739  0.0734780628510703  0.0735163861824624  0.0737867751395327 
                147                 227                 170                 332 
 0.0739031028851388  0.0739470173432438   0.073986308583465  0.0744658345673789 
                356                 206                 119                 130 
 0.0746185336806848   0.074849349825563  0.0753043119455333  0.0755026672137874 
                182                 127                 176                  72 
  0.075534556908353  0.0757384498863923  0.0757575757575758  0.0761194029850746 
                180                 329                  32                 162 
 0.0761608704099475  0.0761834556584725  0.0763305322128851              0.0765 
                206                 238                 147                 206 
 0.0767867139391678  0.0771307365985345  0.0772969491128418   0.077457264957265 
                404                 144                 275                 178 
 0.0775623268698061  0.0777167100568894   0.077766445690974   0.077792732166891 
                214                 355                 110                 292 
 0.0781227011917022  0.0792792792792793  0.0795259032689734  0.0795300497062811 
                243                 186                 408                 189 
 0.0795717592592593  0.0797656602073006  0.0799757649197213  0.0800351802990325 
                146                 245                 126                 151 
 0.0803679496489954  0.0806698903172544  0.0808438558669541   0.081692573402418 
                203                 390                 174                 331 
 0.0819262038774234  0.0821148001605597  0.0821542674577818  0.0829190693974945 
                 81                  35                 205                  67 
 0.0845114315664221  0.0845241304933944  0.0846036585365854  0.0850873264666368 
                171                 154                 125                 181 
 0.0850877192982456   0.085838779956427  0.0871771217712177  0.0871937608509935 
                166                 169                 137                 330 
 0.0872557726465364  0.0879211175020542  0.0880537203509152  0.0883005267535348 
                128                 110                 289                 310 
 0.0885896527285613  0.0895895895895896  0.0897435897435897  0.0903323105725727 
                168                 228                 154                 195 
 0.0906718851924331  0.0907393359397794  0.0907575035731301  0.0909478746509463 
                131                  78                 236                 184 
 0.0913471466923659  0.0918690601900739  0.0919729186043997  0.0920472328923033 
                224                 353                 315                 156 
 0.0925431139179014  0.0926889714993804  0.0931930062807673  0.0936348693532846 
                452                 144                  55                  98 
  0.093978102189781  0.0941611024293223  0.0942935459755794  0.0944649446494465 
                173                 197                  92                 140 
 0.0946155169447789  0.0951444859445646  0.0955528846153846  0.0958322934863988 
                163                 209                 167                 492 
 0.0958677685950413  0.0961078221438468  0.0964175143741707  0.0964261631827377 
                172                  80                 149                 181 
 0.0968399592252803  0.0971563981042654  0.0984356197352587  0.0984398216939079 
                195                 169                 295                  80 
 0.0986763911399244  0.0990077653149267   0.100058147336405   0.101239669421488 
                119                 185                 399                 143 
  0.101467214104577   0.101767857896291   0.102642276422764   0.102649006622517 
                269                 176                 111                 184 
   0.10270393092479   0.102815564694717   0.103008945513689   0.103325799160478 
                157                 134                 167                 105 
  0.103597052549932   0.105719237435009   0.105905511811024    0.10730054175318 
                139                 119                 345                 150 
  0.108005366726297   0.108166470357283   0.109404990403071   0.110151036178433 
                171                 170                 265                 190 
  0.111923920994879   0.112025605852766   0.112173739788803   0.114229765013055 
                130                 202                 178                  73 
  0.114525835974502   0.114706592610481   0.115978211529732   0.116141117702154 
                198                 518                 102                 230 
  0.117099936431463   0.118951612903226   0.119464797706276   0.120465801097577 
                174                 142                 199                 328 
  0.121081745543946              0.1225   0.122544159230289   0.123858909955167 
                102                  73                  54                 269 
  0.124222197081118   0.125036689169357   0.125267338832875    0.12553251917069 
                406                 261                 175                 319 
  0.126307739369838   0.126770467101959   0.131510445635971   0.135149023638232 
                204                 378                 296                 234 
  0.136729555838747   0.145720649061406   0.145816826598586   0.146203845806626 
                383                  95                 388                 188 
    0.1463243873979   0.147475481293135   0.148916657113378   0.152476213710661 
                247                 121                 211                 112 
  0.152999645012425   0.153031761308951   0.154871196536584   0.155465949820789 
                104                 173                 210                 200 
   0.16151983045716   0.162202043132804   0.163961038961039   0.164057181756297 
                186                 454                 210                 196 
  0.167901234567901   0.172022950473442   0.181258488003622   0.182134570765661 
                167                 232                 190                 212 
  0.182632457871565   0.184947958366693   0.185637891520244   0.189697630293488 
                294                 211                 262                 218 
  0.198355345128333   0.203438395415473    0.20463712781353   0.205955334987593 
                243                 341                 276                 319 
  0.234804706537631    0.25564486542374   0.261106454316848   0.279759519038076 
                229                 237                 234                 219 

> ##########################
> #Occupational unemployment risk (isco2d)
> ##########################
> #ESS1-ESS5
> table(data$iscoco)

 100 1000 1100 1110 1140 1141 1142 1143 1200 1210 1220 1221 1222 1223 1224 1225 1226 1227 1228 
 395   61   28  160   10    9   24   17   48  785  230   34  438  191  266  148  175  202   72 
1229 1230 1231 1232 1233 1234 1235 1236 1237 1239 1300 1310 1311 1312 1313 1314 1315 1316 1317 
 546  117  703  268  644  106  128  199  179  544   95  105  298  255  339 1451  654  202  400 
1318 1319 2000 2100 2110 2111 2112 2113 2114 2120 2121 2122 2130 2131 2139 2140 2141 2142 2143 
 164  678   64   35   14   30   12  104   24    2   27   31  224  757  329  104  359  300  144 
2144 2145 2146 2147 2148 2149 2200 2210 2211 2212 2213 2220 2221 2222 2223 2224 2229 2230 2300 
 170  289   76   39   78  530   22   14  126   33   84   17  658  135   69  132  141 1045  314 
2310 2320 2330 2331 2332 2340 2350 2351 2352 2359 2400 2410 2411 2412 2419 2420 2421 2422 2429 
 711 2069  207 1399  217  219   72  132   49  524   49   63  690  356 1014   57  250   59  175 
2430 2431 2432 2440 2441 2442 2443 2444 2445 2446 2450 2451 2452 2453 2454 2455 2460 2470 3000 
  15   65  137   19  170   46   38  129  205  515   28  430  231  158   22  130  138  493   26 
3100 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3130 3131 3132 3133 
  84  140  210  343  186  306  351  105   40  318  614  279  266  229   19    4  191   52   70 
3139 3140 3141 3142 3143 3144 3145 3150 3151 3152 3200 3210 3211 3212 3213 3220 3221 3222 3223 
  24   19   38   82   40   38   18   32   35  448   43   10  207   56   25   46  145   34   50 
3224 3225 3226 3227 3228 3229 3230 3231 3232 3300 3310 3320 3330 3340 3400 3410 3411 3412 3413 
  81  146  406   50  163  343   38 1947   65   58  590  599  141  528  149  246  115  382  225 
3414 3415 3416 3417 3419 3420 3421 3422 3423 3429 3430 3431 3432 3433 3434 3440 3441 3442 3443 
  64 1330  294   65  887   48   94   44  118  222  506 1719  366  759   42   77   44  147  132 
3444 3449 3450 3460 3470 3471 3472 3473 3474 3475 3480 4000 4100 4110 4111 4112 4113 4114 4115 
  42  178  203  894   59  377   25   63   21  229   58  474  298  480  134   49  148   14 1993 
4120 4121 4122 4130 4131 4132 4133 4140 4141 4142 4143 4144 4190 4200 4210 4211 4212 4213 4214 
 323 1266  584   88  970  427  358   11  227  594   27   34 2857  136  179  546  454   27    2 
4215 4220 4221 4222 4223 4290 5000 5100 5110 5111 5112 5113 5120 5121 5122 5123 5130 5131 5132 
  43  143  105  817  454    3   27   51    7  110   99   61  194  366 1584 2021  531 1583 2089 
5133 5139 5140 5141 5142 5143 5149 5160 5161 5162 5163 5169 5200 5210 5220 6000 6100 6110 6111 
1249  402   28 1064   47   27  276   33  142  396   91  337  121   15 7065    6  126   46  521 
6112 6120 6121 6122 6129 6130 6140 6141 6142 6150 6151 6152 6153 6154 7000 7100 7110 7111 7112 
 765   35  619   47   76 1420   92   83    3   34   15   51   27    5   65   31    1   72   13 
7113 7120 7121 7122 7123 7124 7129 7130 7131 7132 7133 7134 7135 7136 7137 7139 7140 7141 7143 
  46  119  316 1032  146 1008  303   20  115  127  122   77   63  592  546   90   28  635   52 
7200 7210 7211 7212 7213 7214 7215 7216 7220 7221 7222 7223 7224 7230 7231 7232 7233 7240 7241 
 121   85   56  408  225  196   21    4   11  135  325  350   62  277  962   56  494   83  604 
7242 7244 7245 7300 7310 7311 7312 7313 7320 7321 7322 7323 7324 7330 7331 7332 7340 7341 7342 
 235  126  136   30    9  152   15   76   12   49   58    2   34   18   56   36   30  161   17 
7343 7344 7345 7346 7400 7410 7411 7412 7413 7414 7415 7416 7420 7421 7422 7423 7424 7430 7431 
  35   48   58   39   49   15  349  402   38   27    5   15   25   63  436   46   11   36   27 
7432 7433 7434 7435 7436 7437 7440 7441 7442 8000 8100 8110 8111 8112 8113 8120 8121 8122 8123 
  88  507   13   52  506   93    1   21  121  122   54   12   24   21   33   20   47   61   25 
8124 8130 8131 8139 8140 8141 8142 8143 8150 8151 8152 8153 8154 8155 8159 8160 8161 8162 8163 
   9    8   39   25   36  121   20   95   70    5    3    4    1   16   34   17   49   41   35 
8170 8200 8210 8211 8212 8220 8221 8222 8223 8224 8229 8230 8231 8232 8240 8250 8251 8252 8253 
  55  124   16  282   44   42   50   13   72   14   32   10   40  159   74   13  162   23   62 
8260 8261 8262 8263 8264 8265 8266 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 
  45  117  126  350  134   10   51  119   82  159   47   26   94   36   11    5   49   15  116 
8281 8282 8283 8284 8285 8286 8287 8290 8300 8310 8311 8312 8320 8321 8322 8323 8324 8330 8331 
 211  170  124   86   49   14   17  647   21    8  148   82  127    5  794  485 1266   42  104 
8332 8333 8334 8340 9000 9100 9110 9111 9113 9120 9130 9131 9132 9133 9140 9141 9142 9150 9151 
 252  191  288   91  198  155   18  101  123    7  643 1630 3606  204    9  743   64   30  568 
9152 9153 9160 9161 9162 9200 9210 9211 9212 9213 9300 9310 9311 9312 9313 9320 9330 
 444   30   27   81  133   19  110  877   37   35   81   18   35  475  471 1323  905 

> table(str_extract(data$iscoco, "^.{2}"))

   10    11    12    13    20    21    22    23    24    30    31    32    33    34    40 
  456   248  6023  4641    64  3678  2476  5913  5682    26  4581  3855  1916 10224   474 
   41    42    50    51    52    60    61    70    71    72    73    74    80    81    82 
10882  2909    27 12788  7201     6  3965    65  5554  4972   935  2946   122   980  4142 
   83    90    91    92    93 
 3904   198  8616  1078  3308 

> data$isco2d<-NA

> data$isco2d<-str_extract(data$iscoco, "^.{2}")

> #ESS6-ESS7
> data$isco08_num<-(as.numeric(as.factor(data$isco08)))

> table(as.numeric(data$isco08)[data$isco08=="Chief executives, senior officials and legislators"])

9 
3 

> table(as.numeric(data$isco08)[data$isco08=="Managing directors and chief executives"])

 15 
401 

> table(data$isco08)[9:15]

Chief executives, senior officials and legislators 
                                                 3 
                  Legislators and senior officials 
                                                 1 
                                       Legislators 
                                                23 
                       Senior government officials 
                                                68 
           Traditional chiefs and heads of village 
                                                 0 
Senior officials of special-interest organizations 
                                                34 
           Managing directors and chief executives 
                                               401 

> for(i in c(9:15)){
+   data$isco2d[data$isco08_num==i]<-11
+ }

> table(data$isco2d)

   10    11    12    13    20    21    22    23    24    30    31    32    33    34    40 
  456   778  6023  4641    64  3678  2476  5913  5682    26  4581  3855  1916 10224   474 
   41    42    50    51    52    60    61    70    71    72    73    74    80    81    82 
10882  2909    27 12788  7201     6  3965    65  5554  4972   935  2946   122   980  4142 
   83    90    91    92    93 
 3904   198  8616  1078  3308 

> table(as.numeric(data$isco08)[data$isco08=="Administrative and commercial managers"])

16 
23 

> table(as.numeric(data$isco08)[data$isco08=="Research and development managers"])

25 
65 

> table(data$isco08)[16:25]

                     Administrative and commercial managers 
                                                         23 
              Business services and administration managers 
                                                         25 
                                           Finance managers 
                                                        173 
                                    Human resource managers 
                                                        115 
                               Policy and planning managers 
                                                         75 
Business services and administration managers not elsewhere 
                                                        193 
                  Sales, marketing and development managers 
                                                          6 
                               Sales and marketing managers 
                                                        288 
                  Advertising and public relations managers 
                                                         18 
                          Research and development managers 
                                                         65 

> for(i in c(16:25)){
+   data$isco2d[data$isco08_num==i]<-12
+ }

> table(as.numeric(data$isco08)[data$isco08=="Production and specialised services managers"])

26 
36 

> table(as.numeric(data$isco08)[data$isco08=="Professional services managers not elsewhere classified"])

 43 
108 

> table(data$isco08)[26:43]

                Production and specialised services managers 
                                                          36 
  Production managers in agriculture, forestry and fisheries 
                                                           0 
               Agricultural and forestry production managers 
                                                          44 
               Aquaculture and fisheries production managers 
                                                           0 
Manufacturing, mining, construction, and distribution manage 
                                                          11 
                                      Manufacturing managers 
                                                         218 
                                             Mining managers 
                                                          13 
                                       Construction managers 
                                                         163 
                   Supply, distribution and related managers 
                                                         136 
  Information and communications technology service managers 
                                                          81 
                              Professional services managers 
                                                           9 
                                Child care services managers 
                                                          35 
                                    Health services managers 
                                                          54 
                                 Aged care services managers 
                                                          26 
                                     Social welfare managers 
                                                          43 
                                          Education managers 
                                                         156 
            Financial and insurance services branch managers 
                                                          91 
     Professional services managers not elsewhere classified 
                                                         108 

> for(i in c(26:43)){
+   data$isco2d[data$isco08_num==i]<-13
+ }

> table(as.numeric(data$isco08)[data$isco08=="Hospitality, retail and other services managers"])

44 
 6 

> table(as.numeric(data$isco08)[data$isco08=="Services managers not elsewhere classified"])

 51 
185 

> table(data$isco08)[44:51]

Hospitality, retail and other services managers 
                                              6 
                  Hotel and restaurant managers 
                                             14 
                                 Hotel managers 
                                             53 
                            Restaurant managers 
                                            195 
            Retail and wholesale trade managers 
                                            324 
                        Other services managers 
                                              1 
Sports, recreation and cultural centre managers 
                                             44 
     Services managers not elsewhere classified 
                                            185 

> for(i in c(44:51)){
+   data$isco2d[data$isco08_num==i]<-14
+ }

> table(as.numeric(data$isco08)[data$isco08=="Science and engineering professionals"])

53 
45 

> table(as.numeric(data$isco08)[data$isco08=="Graphic and multimedia designers"])

82 
99 

> table(data$isco08)[53:82]

                      Science and engineering professionals 
                                                         45 
                   Physical and earth science professionals 
                                                          0 
                                 Physicists and astronomers 
                                                         14 
                                             Meteorologists 
                                                          6 
                                                   Chemists 
                                                         29 
                               Geologists and geophysicists 
                                                         17 
                Mathematicians, actuaries and statisticians 
                                                         24 
                                 Life science professionals 
                                                          2 
Biologists, botanists, zoologists and related professionals 
                                                         54 
                   Farming, forestry and fisheries advisers 
                                                         30 
                     Environmental protection professionals 
                                                         26 
    Engineering professionals (excluding electrotechnology) 
                                                         30 
                        Industrial and production engineers 
                                                         62 
                                            Civil engineers 
                                                        137 
                                    Environmental engineers 
                                                         17 
                                       Mechanical engineers 
                                                        146 
                                         Chemical engineers 
                                                         23 
  Mining engineers, metallurgists and related professionals 
                                                         23 
         Engineering professionals not elsewhere classified 
                                                        132 
                                Electrotechnology engineers 
                                                          2 
                                       Electrical engineers 
                                                         58 
                                      Electronics engineers 
                                                         43 
                               Telecommunications engineers 
                                                         38 
              Architects, planners, surveyors and designers 
                                                         25 
                                        Building architects 
                                                        117 
                                       Landscape architects 
                                                         17 
                              Product and garment designers 
                                                         38 
                                  Town and traffic planners 
                                                         18 
                                Cartographers and surveyors 
                                                         26 
                           Graphic and multimedia designers 
                                                         99 

> for(i in c(44:51)){
+   data$isco2d[data$isco08_num==i]<-21
+ }

> table(as.numeric(data$isco08)[data$isco08=="Health professionals"])

83 
15 

> table(as.numeric(data$isco08)[data$isco08=="Health professionals not elsewhere classified"])

101 
 81 

> table(data$isco08)[83:101]

                                        Health professionals 
                                                          15 
                                             Medical doctors 
                                                          26 
                            Generalist medical practitioners 
                                                         130 
                            Specialist medical practitioners 
                                                         130 
                         Nursing and midwifery professionals 
                                                           3 
                                       Nursing professionals 
                                                         556 
                                     Midwifery professionals 
                                                          26 
        Traditional and complementary medicine professionals 
                                                          14 
                                   Paramedical practitioners 
                                                          15 
                                               Veterinarians 
                                                          22 
                                  Other health professionals 
                                                          14 
                                                    Dentists 
                                                          58 
                                                 Pharmacists 
                                                          62 
Environmental and occupational health and hygiene profession 
                                                          21 
                                            Physiotherapists 
                                                         105 
                                Dieticians and nutritionists 
                                                          23 
                          Audiologists and speech therapists 
                                                          20 
                       Optometrists and ophthalmic opticians 
                                                          16 
               Health professionals not elsewhere classified 
                                                          81 

> for(i in c(83:101)){
+   data$isco2d[data$isco08_num==i]<-22
+ }

> table(as.numeric(data$isco08)[data$isco08=="Teaching professionals"])

102 
189 

> table(as.numeric(data$isco08)[data$isco08=="Teaching professionals not elsewhere classified"])

116 
139 

> table(data$isco08)[102:116]

                         Teaching professionals 
                                            189 
       University and higher education teachers 
                                            302 
                  Vocational education teachers 
                                            228 
                   Secondary education teachers 
                                            733 
    Primary school and early childhood teachers 
                                             13 
                        Primary school teachers 
                                            732 
                      Early childhood educators 
                                            310 
                   Other teaching professionals 
                                             10 
                  Education methods specialists 
                                             46 
                         Special needs teachers 
                                            167 
                        Other language teachers 
                                             32 
                           Other music teachers 
                                             37 
                            Other arts teachers 
                                             43 
                Information technology trainers 
                                             15 
Teaching professionals not elsewhere classified 
                                            139 

> for(i in c(102:116)){
+   data$isco2d[data$isco08_num==i]<-23
+ }

> table(as.numeric(data$isco08)[data$isco08=="Business and administration professionals"])

117 
 58 

> table(as.numeric(data$isco08)[data$isco08=="Information and communications technology sales professional"])

131 
 39 

> table(data$isco08)[117:131]

                   Business and administration professionals 
                                                          58 
                                       Finance professionals 
                                                          15 
                                                 Accountants 
                                                         267 
                           Financial and investment advisers 
                                                         144 
                                          Financial analysts 
                                                          60 
                                Administration professionals 
                                                          14 
                        Management and organization analysts 
                                                         230 
                         Policy administration professionals 
                                                         239 
                         Personnel and careers professionals 
                                                         107 
                Training and staff development professionals 
                                                         100 
         Sales, marketing and public relations professionals 
                                                          12 
                     Advertising and marketing professionals 
                                                         158 
                              Public relations professionals 
                                                          66 
   Technical and medical sales professionals (excluding ICT) 
                                                         143 
Information and communications technology sales professional 
                                                          39 

> for(i in c(117:131)){
+   data$isco2d[data$isco08_num==i]<-24
+ }

> table(as.numeric(data$isco08)[data$isco08=="Information and communications technology professionals"])

132 
 40 

> table(as.numeric(data$isco08)[data$isco08=="Database and network professionals not elsewhere classified"])

143 
 21 

> table(data$isco08)[132:143]

     Information and communications technology professionals 
                                                          40 
           Software and applications developers and analysts 
                                                          13 
                                            Systems analysts 
                                                         129 
                                         Software developers 
                                                         171 
                               Web and multimedia developers 
                                                          34 
                                    Applications programmers 
                                                          60 
Software and applications developers and analysts not elsewh 
                                                          86 
                          Database and network professionals 
                                                           0 
                       Database designers and administrators 
                                                          20 
                                      Systems administrators 
                                                          37 
                              Computer network professionals 
                                                          31 
 Database and network professionals not elsewhere classified 
                                                          21 

> for(i in c(117:131)){
+   data$isco2d[data$isco08_num==i]<-25
+ }

> table(as.numeric(data$isco08)[data$isco08=="Legal, social and cultural professionals"])

144 
  8 

> table(as.numeric(data$isco08)[data$isco08=="Creative and performing artists not elsewhere classified"])

170 
 19 

> table(data$isco08)[144:170]

                Legal, social and cultural professionals 
                                                       8 
                                     Legal professionals 
                                                      12 
                                                 Lawyers 
                                                     100 
                                                  Judges 
                                                      19 
            Legal professionals not elsewhere classified 
                                                      86 
                     Librarians, archivists and curators 
                                                       9 
                                 Archivists and curators 
                                                      26 
        Librarians and related information professionals 
                                                      56 
                      Social and religious professionals 
                                                       7 
                                              Economists 
                                                      36 
 Sociologists, anthropologists and related professionals 
                                                      15 
       Philosophers, historians and political scientists 
                                                      10 
                                           Psychologists 
                                                     122 
               Social work and counselling professionals 
                                                     272 
                                 Religious professionals 
                                                      56 
                      Authors, journalists and linguists 
                                                       0 
                             Authors and related writers 
                                                      35 
                                             Journalists 
                                                     145 
           Translators, interpreters and other linguists 
                                                      60 
                         Creative and performing artists 
                                                      17 
                                          Visual artists 
                                                      32 
                        Musicians, singers and composers 
                                                     105 
                              Dancers and choreographers 
                                                      10 
         Film, stage and related directors and producers 
                                                      39 
                                                  Actors 
                                                      25 
         Announcers on radio, television and other media 
                                                       4 
Creative and performing artists not elsewhere classified 
                                                      19 

> for(i in c(117:131)){
+   data$isco2d[data$isco08_num==i]<-26
+ }

> table(as.numeric(data$isco08)[data$isco08=="Science and engineering associate professionals"])

172 
 32 

> table(as.numeric(data$isco08)[data$isco08=="Air traffic safety electronics technicians"])

203 
  7 

> table(data$isco08)[172:203]

             Science and engineering associate professionals 
                                                          32 
                Physical and engineering science technicians 
                                                          32 
                   Chemical and physical science technicians 
                                                          64 
                               Civil engineering technicians 
                                                         126 
                          Electrical engineering technicians 
                                                          94 
                         Electronics engineering technicians 
                                                          59 
                          Mechanical engineering technicians 
                                                         142 
                            Chemical engineering technicians 
                                                          32 
                        Mining and metallurgical technicians 
                                                          37 
                                             Draughtspersons 
                                                         113 
Physical and engineering science technicians not elsewhere c 
                                                         184 
          Mining, manufacturing and construction supervisors 
                                                          21 
                                          Mining supervisors 
                                                           5 
                                   Manufacturing supervisors 
                                                         226 
                                    Construction supervisors 
                                                         192 
                                 Process control technicians 
                                                           4 
                            Power production plant operators 
                                                          20 
             Incinerator and water treatment plant operators 
                                                          19 
                       Chemical processing plant controllers 
                                                          21 
          Petroleum and natural gas refining plant operators 
                                                          15 
                        Metal production process controllers 
                                                          15 
        Process control technicians not elsewhere classified 
                                                          78 
Life science technicians and related associate professionals 
                                                           0 
                Life science technicians (excluding medical) 
                                                          25 
                                    Agricultural technicians 
                                                          33 
                                        Forestry technicians 
                                                          16 
               Ship and aircraft controllers and technicians 
                                                           3 
                                            Ships' engineers 
                                                          18 
                             Ships' deck officers and pilots 
                                                          36 
         Aircraft pilots and related associate professionals 
                                                          25 
                                     Air traffic controllers 
                                                           8 
                  Air traffic safety electronics technicians 
                                                           7 

> for(i in c(117:131)){
+   data$isco2d[data$isco08_num==i]<-31
+ }

> table(as.numeric(data$isco08)[data$isco08=="Health associate professionals"])

204 
 15 

> table(as.numeric(data$isco08)[data$isco08=="Health associate professionals not elsewhere classified"])

224 
 63 

> table(data$isco08)[204:224]

                              Health associate professionals 
                                                          15 
                      Medical and pharmaceutical technicians 
                                                           3 
       Medical imaging and therapeutic equipment technicians 
                                                          41 
                Medical and pathology laboratory technicians 
                                                         105 
                   Pharmaceutical technicians and assistants 
                                                          91 
                   Medical and dental prosthetic technicians 
                                                          29 
               Nursing and midwifery associate professionals 
                                                           1 
                             Nursing associate professionals 
                                                         574 
                           Midwifery associate professionals 
                                                          13 
Traditional and complementary medicine associate professiona 
                                                          15 
                       Veterinary technicians and assistants 
                                                          19 
                        Other health associate professionals 
                                                           0 
                            Dental assistants and therapists 
                                                          62 
          Medical records and health information technicians 
                                                           6 
                                    Community health workers 
                                                          23 
                                        Dispensing opticians 
                                                          15 
                    Physiotherapy technicians and assistants 
                                                          37 
                                          Medical assistants 
                                                          61 
Environmental and occupational health inspectors and associa 
                                                          65 
                                           Ambulance workers 
                                                          36 
     Health associate professionals not elsewhere classified 
                                                          63 

> for(i in c(204:224)){
+   data$isco2d[data$isco08_num==i]<-32
+ }

> table(as.numeric(data$isco08)[data$isco08=="Business and administration associate professionals"])

225 
 43 

> table(as.numeric(data$isco08)[data$isco08=="Regulatory government associate professionals not elsewhere"])

254 
118 

> table(data$isco08)[225:254]

         Business and administration associate professionals 
                                                          43 
          Financial and mathematical associate professionals 
                                                          23 
                  Securities and finance dealers and brokers 
                                                          38 
                                   Credit and loans officers 
                                                          83 
                          Accounting associate professionals 
                                                         360 
Statistical, mathematical and related associate professional 
                                                          19 
                                  Valuers and loss assessors 
                                                          22 
                     Sales and purchasing agents and brokers 
                                                          23 
                                   Insurance representatives 
                                                         165 
                            Commercial sales representatives 
                                                         451 
                                                      Buyers 
                                                         141 
                                               Trade brokers 
                                                          68 
                                    Business services agents 
                                                          18 
                              Clearing and forwarding agents 
                                                          39 
                               Conference and event planners 
                                                          54 
                           Employment agents and contractors 
                                                          57 
                    Real estate agents and property managers 
                                                         113 
           Business services agents not elsewhere classified 
                                                          82 
                  Administrative and specialised secretaries 
                                                          24 
                                          Office supervisors 
                                                         244 
                                           Legal secretaries 
                                                          50 
                    Administrative and executive secretaries 
                                                         534 
                                         Medical secretaries 
                                                         106 
               Regulatory government associate professionals 
                                                          54 
                               Customs and border inspectors 
                                                          28 
                         Government tax and excise officials 
                                                          54 
                        Government social benefits officials 
                                                         115 
                              Government licensing officials 
                                                          24 
                            Police inspectors and detectives 
                                                          85 
 Regulatory government associate professionals not elsewhere 
                                                         118 

> for(i in c(225:254)){
+   data$isco2d[data$isco08_num==i]<-33
+ }

> table(as.numeric(data$isco08)[data$isco08=="Legal, social, cultural and related associate professionals"])

255 
 10 

> table(as.numeric(data$isco08)[data$isco08=="Other artistic and cultural associate professionals"])

269 
 39 

> table(data$isco08)[255:269]

Legal, social, cultural and related associate professionals 
                                                         10 
        Legal, social and religious associate professionals 
                                                          2 
                           Police inspectors and detectives 
                                                         76 
                        Social work associate professionals 
                                                        351 
                          Religious associate professionals 
                                                         32 
                                 Sports and fitness workers 
                                                         12 
                                Athletes and sports players 
                                                         14 
                  Sports coaches, instructors and officials 
                                                        116 
     Fitness and recreation instructors and program leaders 
                                                         91 
    Artistic, cultural and culinary associate professionals 
                                                          3 
                                              Photographers 
                                                         49 
                          Interior designers and decorators 
                                                         48 
                    Gallery, museum and library technicians 
                                                         15 
                                                      Chefs 
                                                        132 
        Other artistic and cultural associate professionals 
                                                         39 

> for(i in c(255:269)){
+   data$isco2d[data$isco08_num==i]<-34
+ }

> table(as.numeric(data$isco08)[data$isco08=="Information and communications technicians"])

270 
  1 

> table(as.numeric(data$isco08)[data$isco08=="Telecommunications engineering technicians"])

278 
 57 

> table(data$isco08)[270:278]

                  Information and communications technicians 
                                                           1 
Information and communications technology operations and use 
                                                          33 
Information and communications technology operations technic 
                                                          43 
Information and communications technology user support techn 
                                                          64 
                    Computer network and systems technicians 
                                                          43 
                                             Web technicians 
                                                          17 
             Telecommunications and broadcasting technicians 
                                                           5 
                   Broadcasting and audio-visual technicians 
                                                          56 
                  Telecommunications engineering technicians 
                                                          57 

> for(i in c(270:278)){
+   data$isco2d[data$isco08_num==i]<-35
+ }

> table(as.numeric(data$isco08)[data$isco08=="General and keyboard clerks"])

280 
 13 

> table(as.numeric(data$isco08)[data$isco08=="Data entry clerks"])

285 
 40 

> table(data$isco08)[280:285]

          General and keyboard clerks                 General office clerks 
                                   13                                   924 
                Secretaries (general)                    Keyboard operators 
                                  557                                     1 
Typists and word processing operators                     Data entry clerks 
                                   47                                    40 

> for(i in c(280:285)){
+   data$isco2d[data$isco08_num==i]<-41
+ }

> table(as.numeric(data$isco08)[data$isco08=="Customer services clerks"])

286 
 31 

> table(as.numeric(data$isco08)[data$isco08=="Client information workers not elsewhere classified"])

300 
 76 

> table(data$isco08)[286:300]

                           Customer services clerks 
                                                 31 
       Tellers, money collectors and related clerks 
                                                 14 
                    Bank tellers and related clerks 
                                                213 
   Bookmakers, croupiers and related gaming workers 
                                                 18 
                      Pawnbrokers and money-lenders 
                                                  0 
                Debt-collectors and related workers 
                                                 43 
                         Client information workers 
                                                  8 
                      Travel consultants and clerks 
                                                 62 
                  Contact centre information clerks 
                                                112 
                    Telephone switchboard operators 
                                                 73 
                                Hotel receptionists 
                                                 62 
                                     Enquiry clerks 
                                                 87 
                            Receptionists (general) 
                                                218 
            Survey and market research interviewers 
                                                 34 
Client information workers not elsewhere classified 
                                                 76 

> for(i in c(286:300)){
+   data$isco2d[data$isco08_num==i]<-42
+ }

> table(as.numeric(data$isco08)[data$isco08=="Numerical and material recording clerks"])

301 
  8 

> table(as.numeric(data$isco08)[data$isco08=="Transport clerks"])

309 
131 

> table(data$isco08)[301:309]

  Numerical and material recording clerks                          Numerical clerks 
                                        8                                        10 
        Accounting and bookkeeping clerks Statistical, finance and insurance clerks 
                                      419                                       192 
                           Payroll clerks   Material-recording and transport clerks 
                                       87                                        15 
                             Stock clerks                         Production clerks 
                                      350                                        76 
                         Transport clerks 
                                      131 

> for(i in c(301:309)){
+   data$isco2d[data$isco08_num==i]<-43
+ }

> table(as.numeric(data$isco08)[data$isco08=="Other clerical support workers"])

310 311 
  5   4 

> table(as.numeric(data$isco08)[data$isco08=="Clerical support workers not elsewhere classified"])

318 
187 

> table(data$isco08)[310:318]

                   Other clerical support workers 
                                                5 
                   Other clerical support workers 
                                                4 
                                   Library clerks 
                                               53 
                 Mail carriers and sorting clerks 
                                              255 
         Coding, proof-reading and related clerks 
                                                4 
                      Scribes and related workers 
                                                5 
                        Filing and copying clerks 
                                               30 
                                 Personnel clerks 
                                               72 
Clerical support workers not elsewhere classified 
                                              187 

> for(i in c(310:318)){
+   data$isco2d[data$isco08_num==i]<-44
+ }

> table(as.numeric(data$isco08)[data$isco08=="Personal service workers"])

320 
 13 

> table(as.numeric(data$isco08)[data$isco08=="Personal services workers not elsewhere classified"])

342 
 43 

> table(data$isco08)[320:342]

                                    Personal service workers 
                                                          13 
                    Travel attendants, conductors and guides 
                                                          10 
                       Travel attendants and travel stewards 
                                                          47 
                                        Transport conductors 
                                                          19 
                                               Travel guides 
                                                          42 
                                                       Cooks 
                                                         439 
                                      Waiters and bartenders 
                                                           7 
                                                     Waiters 
                                                         585 
                                                  Bartenders 
                                                         205 
               Hairdressers, beauticians and related workers 
                                                          11 
                                                Hairdressers 
                                                         303 
                             Beauticians and related workers 
                                                          99 
                       Building and housekeeping supervisors 
                                                          11 
Cleaning and housekeeping supervisors in offices, hotels and 
                                                         121 
                                       Domestic housekeepers 
                                                          51 
                                         Building caretakers 
                                                         334 
                             Other personal services workers 
                                                           8 
            Astrologers, fortune-tellers and related workers 
                                                           1 
                                       Companions and valets 
                                                          14 
                                   Undertakers and embalmers 
                                                          16 
                        Pet groomers and animal care workers 
                                                          50 
                                         Driving instructors 
                                                          32 
          Personal services workers not elsewhere classified 
                                                          43 

> for(i in c(320:342)){
+   data$isco2d[data$isco08_num==i]<-51
+ }

> table(as.numeric(data$isco08)[data$isco08=="Sales workers"])

343 
 73 

> table(as.numeric(data$isco08)[data$isco08=="Sales workers not elsewhere classified"])

359 
 94 

> table(data$isco08)[343:359]

                         Sales workers         Street and market salespersons 
                                    73                                      2 
         Stall and market salespersons               Street food salespersons 
                                    45                                     25 
                     Shop salespersons                           Shop keepers 
                                    56                                    338 
                      Shop supervisors                  Shop sales assistants 
                                   254                                   2030 
            Cashiers and ticket clerks                    Other sales workers 
                                   407                                      4 
              Fashion and other models                    Sales demonstrators 
                                     5                                     27 
             Door to door salespersons            Contact centre salespersons 
                                    22                                     70 
            Service station attendants        Food service counter attendants 
                                    33                                    181 
Sales workers not elsewhere classified 
                                    94 

> for(i in c(343:359)){
+   data$isco2d[data$isco08_num==i]<-51
+ }

> table(as.numeric(data$isco08)[data$isco08=="Personal care workers"])

360 
  2 

> table(as.numeric(data$isco08)[data$isco08=="Personal care workers in health services not elsewhere class"])

367 
183 

> table(data$isco08)[360:367]

                                       Personal care workers 
                                                           2 
                      Child care workers and teachers' aides 
                                                          15 
                                          Child care workers 
                                                         638 
                                             Teachers' aides 
                                                         193 
                    Personal care workers in health services 
                                                          47 
                                      Health care assistants 
                                                         895 
                            Home-based personal care workers 
                                                         531 
Personal care workers in health services not elsewhere class 
                                                         183 

> for(i in c(360:367)){
+   data$isco2d[data$isco08_num==i]<-53
+ }

> table(as.numeric(data$isco08)[data$isco08=="Protective services workers"])

369 
  5 

> table(as.numeric(data$isco08)[data$isco08=="Protective services workers not elsewhere classified"])

374 
 25 

> table(data$isco08)[369:374]

                         Protective services workers 
                                                   5 
                                       Fire-fighters 
                                                  70 
                                     Police officers 
                                                 207 
                                       Prison guards 
                                                  37 
                                     Security guards 
                                                 238 
Protective services workers not elsewhere classified 
                                                  25 

> for(i in c(369:374)){
+   data$isco2d[data$isco08_num==i]<-54
+ }

> table(as.numeric(data$isco08)[data$isco08=="Market-oriented skilled agricultural workers"])

376 
  9 

> table(as.numeric(data$isco08)[data$isco08=="Mixed crop and animal producers"])

387 
337 

> table(data$isco08)[376:387]

Market-oriented skilled agricultural workers            Market gardeners and crop growers 
                                           9                                            8 
            Field crop and vegetable growers                  Tree and shrub crop growers 
                                         123                                           61 
Gardeners, horticultural and nursery growers                           Mixed crop growers 
                                         261                                           34 
                            Animal producers                Livestock and dairy producers 
                                           7                                          233 
                           Poultry producers                 Apiarists and sericulturists 
                                           8                                            5 
   Animal producers not elsewhere classified              Mixed crop and animal producers 
                                          21                                          337 

> for(i in c(376:387)){
+   data$isco2d[data$isco08_num==i]<-61
+ }

> table(as.numeric(data$isco08)[data$isco08=="Market-oriented skilled forestry, fishery and hunting worker"])
< table of extent 0 >

> table(as.numeric(data$isco08)[data$isco08=="Hunters and trappers"])
< table of extent 0 >

> table(data$isco08)[388:394]

Market-oriented skilled forestry, fishery and hunting worker 
                                                           0 
                                Forestry and related workers 
                                                          68 
                       Fishery workers, hunters and trappers 
                                                           1 
                                         Aquaculture workers 
                                                           5 
                   Inland and coastal waters fishery workers 
                                                          16 
                                    Deep-sea fishery workers 
                                                          13 
                                        Hunters and trappers 
                                                           0 

> for(i in c(388:394)){
+   data$isco2d[data$isco08_num==i]<-62
+ }

> table(as.numeric(data$isco08)[data$isco08=="Subsistence farmers, fishers, hunters and gatherers"])

395 
  3 

> table(as.numeric(data$isco08)[data$isco08=="Subsistence fishers, hunters, trappers and gatherers"])

399 
  4 

> table(data$isco08)[395:399]

 Subsistence farmers, fishers, hunters and gatherers 
                                                   3 
                            Subsistence crop farmers 
                                                  55 
                       Subsistence livestock farmers 
                                                  21 
        Subsistence mixed crop and livestock farmers 
                                                 132 
Subsistence fishers, hunters, trappers and gatherers 
                                                   4 

> for(i in c(395:399)){
+   data$isco2d[data$isco08_num==i]<-63
+ }

> table(as.numeric(data$isco08)[data$isco08=="Building and related trades workers, excluding electricians"])

401 
 12 

> table(as.numeric(data$isco08)[data$isco08=="Building structure cleaners"])

420 
 22 

> table(data$isco08)[401:420]

 Building and related trades workers, excluding electricians 
                                                          12 
                   Building frame and related trades workers 
                                                          14 
                                              House builders 
                                                         137 
                             Bricklayers and related workers 
                                                         325 
           Stonemasons, stone cutters, splitters and carvers 
                                                          25 
    Concrete placers, concrete finishers and related workers 
                                                          58 
                                      Carpenters and joiners 
                                                         393 
Building frame and related trades workers not elsewhere clas 
                                                          90 
               Building finishers and related trades workers 
                                                          20 
                                                     Roofers 
                                                          58 
                               Floor layers and tile setters 
                                                          59 
                                                  Plasterers 
                                                          52 
                                          Insulation workers 
                                                          38 
                                                    Glaziers 
                                                          19 
                                   Plumbers and pipe fitters 
                                                         223 
                Air conditioning and refrigeration mechanics 
                                                          36 
Painters, building structure cleaners and related trades wor 
                                                           1 
                                Painters and related workers 
                                                         229 
                               Spray painters and varnishers 
                                                          55 
                                 Building structure cleaners 
                                                          22 

> for(i in c(401:420)){
+   data$isco2d[data$isco08_num==i]<-71
+ }

> table(as.numeric(data$isco08)[data$isco08=="Metal, machinery and related trades workers"])

421 
 38 

> table(as.numeric(data$isco08)[data$isco08=="Bicycle and related repairers"])

437 
 18 

> table(data$isco08)[421:437]

                 Metal, machinery and related trades workers 
                                                          38 
Sheet and structural metal workers, moulders and welders, an 
                                                          19 
                               Metal moulders and coremakers 
                                                          25 
                                    Welders and flamecutters 
                                                         157 
                                         Sheet-metal workers 
                                                          73 
                     Structural-metal preparers and erectors 
                                                          90 
                                  Riggers and cable splicers 
                                                           8 
          Blacksmiths, toolmakers and related trades workers 
                                                           3 
         Blacksmiths, hammersmiths and forging press workers 
                                                          34 
                              Toolmakers and related workers 
                                                          93 
            Metal working machine tool setters and operators 
                                                         168 
         Metal polishers, wheel grinders and tool sharpeners 
                                                          24 
                           Machinery mechanics and repairers 
                                                          33 
                       Motor vehicle mechanics and repairers 
                                                         363 
                     Aircraft engine mechanics and repairers 
                                                          26 
Agricultural and industrial machinery mechanics and repairer 
                                                         215 
                               Bicycle and related repairers 
                                                          18 

> for(i in c(421:437)){
+   data$isco2d[data$isco08_num==i]<-72
+ }

> table(as.numeric(data$isco08)[data$isco08=="Handicraft and printing workers"])
< table of extent 0 >

> table(as.numeric(data$isco08)[data$isco08=="Print finishing and binding workers"])

452 
 27 

> table(data$isco08)[438:452]

                             Handicraft and printing workers 
                                                           0 
                                          Handicraft workers 
                                                           2 
                   Precision-instrument makers and repairers 
                                                          32 
                        Musical instrument makers and tuners 
                                                           4 
                        Jewellery and precious-metal workers 
                                                          15 
                                 Potters and related workers 
                                                          13 
               Glass makers, cutters, grinders and finishers 
                                                          18 
    Sign writers, decorative painters, engravers and etchers 
                                                          12 
  Handicraft workers in wood, basketry and related materials 
                                                           9 
Handicraft workers in textile, leather and related materials 
                                                          27 
                 Handicraft workers not elsewhere classified 
                                                          13 
                                     Printing trades workers 
                                                           8 
                                       Pre-press technicians 
                                                          38 
                                                    Printers 
                                                         101 
                         Print finishing and binding workers 
                                                          27 

> for(i in c(438:452)){
+   data$isco2d[data$isco08_num==i]<-73
+ }

> table(as.numeric(data$isco08)[data$isco08=="Electrical and electronic trades workers"])

453 
  5 

> table(as.numeric(data$isco08)[data$isco08=="Information and communications technology installers and ser"])

460 
 60 

> table(data$isco08)[453:460]

                    Electrical and electronic trades workers 
                                                           5 
               Electrical equipment installers and repairers 
                                                          12 
                           Building and related electricians 
                                                         256 
                            Electrical mechanics and fitters 
                                                         118 
                    Electrical line installers and repairers 
                                                          28 
 Electronics and telecommunications installers and repairers 
                                                           4 
                         Electronics mechanics and servicers 
                                                          76 
Information and communications technology installers and ser 
                                                          60 

> for(i in c(453:460)){
+   data$isco2d[data$isco08_num==i]<-74
+ }

> table(as.numeric(data$isco08)[data$isco08=="Food processing, wood working, garment and other craft and r"])

461 
 12 

> table(as.numeric(data$isco08)[data$isco08=="Craft and related workers not elsewhere classified"])

485 
 46 

> table(data$isco08)[461:485]

Food processing, wood working, garment and other craft and r 
                                                          12 
                  Food processing and related trades workers 
                                                           7 
            Butchers, fishmongers and related food preparers 
                                                         141 
               Bakers, pastry-cooks and confectionery makers 
                                                         137 
                                       Dairy-products makers 
                                                          20 
                     Fruit, vegetable and related preservers 
                                                           4 
                       Food and beverage tasters and graders 
                                                          11 
               Tobacco preparers and tobacco products makers 
                                                           4 
    Wood treaters, cabinet-makers and related trades workers 
                                                          10 
                                               Wood treaters 
                                                          14 
                          Cabinet-makers and related workers 
                                                         159 
              Woodworking-machine tool setters and operators 
                                                          30 
                          Garment and related trades workers 
                                                           6 
                  Tailors, dressmakers, furriers and hatters 
                                                         195 
              Garment and related pattern-makers and cutters 
                                                           9 
                      Sewing, embroidery and related workers 
                                                          82 
                            Upholsterers and related workers 
                                                          25 
                      Pelt dressers, tanners and fellmongers 
                                                           2 
                              Shoemakers and related workers 
                                                          20 
                             Other craft and related workers 
                                                           0 
                                           Underwater divers 
                                                           3 
                                     Shotfirers and blasters 
                                                           4 
 Product graders and testers (excluding foods and beverages) 
                                                          71 
              Fumigators and other pest and weed controllers 
                                                           4 
          Craft and related workers not elsewhere classified 
                                                          46 

> for(i in c(461:485)){
+   data$isco2d[data$isco08_num==i]<-75
+ }

> table(as.numeric(data$isco08)[data$isco08=="Stationary plant and machine operators"])

487 
 60 

> table(as.numeric(data$isco08)[data$isco08=="Stationary plant and machine operators not elsewhere classif"])

520 
155 

> table(data$isco08)[487:520]

                      Stationary plant and machine operators 
                                                          60 
               Mining and mineral processing plant operators 
                                                           1 
                                        Miners and quarriers 
                                                          27 
                Mineral and stone processing plant operators 
                                                           4 
                Well drillers and borers and related workers 
                                                          17 
  Cement, stone and other mineral products machine operators 
                                                          16 
              Metal processing and finishing plant operators 
                                                          11 
                            Metal processing plant operators 
                                                          88 
      Metal finishing, plating and coating machine operators 
                                                          33 
Chemical and photographic products plant and machine operato 
                                                           0 
               Chemical products plant and machine operators 
                                                          55 
                     Photographic products machine operators 
                                                           9 
        Rubber, plastic and paper products machine operators 
                                                           2 
                           Rubber products machine operators 
                                                          14 
                          Plastic products machine operators 
                                                          62 
                            Paper products machine operators 
                                                          22 
         Textile, fur and leather products machine operators 
                                                          23 
     Fibre preparing, spinning and winding machine operators 
                                                          54 
                      Weaving and knitting machine operators 
                                                          50 
                                    Sewing machine operators 
                                                         139 
     Bleaching, dyeing and fabric cleaning machine operators 
                                                           6 
                 Fur and leather preparing machine operators 
                                                           5 
                    Shoemaking and related machine operators 
                                                          45 
                                   Laundry machine operators 
                                                          38 
Textile, fur and leather products machine operators not else 
                                                          14 
                 Food and related products machine operators 
                                                         168 
             Wood processing and papermaking plant operators 
                                                           0 
                        Pulp and papermaking plant operators 
                                                          34 
                             Wood processing plant operators 
                                                          41 
                Other stationary plant and machine operators 
                                                           2 
                          Glass and ceramics plant operators 
                                                          15 
                           Steam engine and boiler operators 
                                                          15 
           Packing, bottling and labelling machine operators 
                                                         118 
Stationary plant and machine operators not elsewhere classif 
                                                         155 

> for(i in c(487:520)){
+   data$isco2d[data$isco08_num==i]<-81
+ }

> table(as.numeric(data$isco08)[data$isco08=="Assemblers"])

521 522 
 10  54 

> table(as.numeric(data$isco08)[data$isco08=="Assemblers not elsewhere classified"])

525 
 63 

> table(data$isco08)[521:525]

                                    Assemblers                                     Assemblers 
                                            10                                             54 
               Mechanical machinery assemblers Electrical and electronic equipment assemblers 
                                            82                                             92 
           Assemblers not elsewhere classified 
                                            63 

> for(i in c(521:525)){
+   data$isco2d[data$isco08_num==i]<-82
+ }

> table(as.numeric(data$isco08)[data$isco08=="Drivers and mobile plant operators"])

526 
 32 

> table(as.numeric(data$isco08)[data$isco08=="Ships' deck crews and related workers"])

541 
 24 

> table(data$isco08)[526:541]

           Drivers and mobile plant operators Locomotive engine drivers and related workers 
                                           32                                             7 
                    Locomotive engine drivers    Railway brake, signal and switch operators 
                                           42                                            24 
              Car, van and motorcycle drivers                            Motorcycle drivers 
                                           26                                             6 
                    Car, taxi and van drivers                   Heavy truck and bus drivers 
                                          384                                            10 
                         Bus and tram drivers                 Heavy truck and lorry drivers 
                                          183                                           575 
                       Mobile plant operators      Mobile farm and forestry plant operators 
                                           13                                            52 
      Earthmoving and related plant operators      Crane, hoist and related plant operators 
                                          130                                            86 
                      Lifting truck operators         Ships' deck crews and related workers 
                                          112                                            24 

> for(i in c(526:541)){
+   data$isco2d[data$isco08_num==i]<-83
+ }

> table(as.numeric(data$isco08)[data$isco08=="Cleaners and helpers"])

543 
 34 

> table(as.numeric(data$isco08)[data$isco08=="Other cleaning workers"])

551 
 62 

> table(data$isco08)[543:551]

                                        Cleaners and helpers 
                                                          34 
             Domestic, hotel and office cleaners and helpers 
                                                         113 
                               Domestic cleaners and helpers 
                                                         580 
Cleaners and helpers in offices, hotels and other establishm 
                                                        1202 
    Vehicle, window, laundry and other hand cleaning workers 
                                                           0 
                                Hand launderers and pressers 
                                                          52 
                                            Vehicle cleaners 
                                                          27 
                                             Window cleaners 
                                                          13 
                                      Other cleaning workers 
                                                          62 

> for(i in c(543:551)){
+   data$isco2d[data$isco08_num==i]<-91
+ }

> table(as.numeric(data$isco08)[data$isco08=="Agricultural, forestry and fishery labourers"])

553 
  4 

> table(as.numeric(data$isco08)[data$isco08=="Fishery and aquaculture labourers"])

559 
  2 

> table(data$isco08)[553:559]

Agricultural, forestry and fishery labourers                          Crop farm labourers 
                                           4                                          115 
                    Livestock farm labourers      Mixed crop and livestock farm labourers 
                                         139                                           59 
          Garden and horticultural labourers                           Forestry labourers 
                                          77                                           17 
           Fishery and aquaculture labourers 
                                           2 

> for(i in c(553:559)){
+   data$isco2d[data$isco08_num==i]<-92
+ }

> table(as.numeric(data$isco08)[data$isco08=="Labourers in mining, construction, manufacturing and transpo"])

560 
 14 

> table(as.numeric(data$isco08)[data$isco08=="Shelf fillers"])

572 
183 

> table(data$isco08)[560:572]

Labourers in mining, construction, manufacturing and transpo 
                                                          14 
                           Mining and construction labourers 
                                                          16 
                              Mining and quarrying labourers 
                                                           4 
                                 Civil engineering labourers 
                                                         105 
                             Building construction labourers 
                                                         249 
                                     Manufacturing labourers 
                                                          72 
                                                Hand packers 
                                                         190 
            Manufacturing labourers not elsewhere classified 
                                                         192 
                             Transport and storage labourers 
                                                          22 
                              Hand and pedal vehicle drivers 
                                                           3 
              Drivers of animal-drawn vehicles and machinery 
                                                           1 
                                            Freight handlers 
                                                         282 
                                               Shelf fillers 
                                                         183 

> for(i in c(560:572)){
+   data$isco2d[data$isco08_num==i]<-93
+ }

> table(as.numeric(data$isco08)[data$isco08=="Food preparation assistants"])

573 574 
 12  21 

> table(as.numeric(data$isco08)[data$isco08=="Kitchen helpers"])

576 
381 

> table(data$isco08)[573:576]

Food preparation assistants Food preparation assistants         Fast food preparers 
                         12                          21                          45 
            Kitchen helpers 
                        381 

> for(i in c(573:576)){
+   data$isco2d[data$isco08_num==i]<-94
+ }

> table(as.numeric(data$isco08)[data$isco08=="Street and related sales and service workers"])
< table of extent 0 >

> table(as.numeric(data$isco08)[data$isco08=="Street vendors (excluding food)"])

579 
 18 

> table(data$isco08)[577:579]

Street and related sales and service workers           Street and related service workers 
                                           0                                           14 
             Street vendors (excluding food) 
                                          18 

> for(i in c(577:579)){
+   data$isco2d[data$isco08_num==i]<-95
+ }

> table(as.numeric(data$isco08)[data$isco08=="Refuse workers and other elementary workers"])

580 
  2 

> table(as.numeric(data$isco08)[data$isco08=="Elementary workers not elsewhere classified"])

590 
100 

> table(data$isco08)[580:590]

       Refuse workers and other elementary workers 
                                                 2 
                                    Refuse workers 
                                                11 
                  Garbage and recycling collectors 
                                                28 
                                    Refuse sorters 
                                                14 
                    Sweepers and related labourers 
                                                50 
                          Other elementary workers 
                                                 0 
Messengers, package deliverers and luggage porters 
                                               142 
                                   Odd job persons 
                                                94 
      Meter readers and vending-machine collectors 
                                                11 
                     Water and firewood collectors 
                                                 2 
       Elementary workers not elsewhere classified 
                                               100 

> for(i in c(580:590)){
+   data$isco2d[data$isco08_num==i]<-96
+ }

> table(data$isco2d)

   10    11    12    13    20    21    22    23    24    30    31    32    33    34    35 
  456   778  7004  5865    64  4500  3813  8909  5682    26  6233  5129  5151 11214   319 
   40    41    42    43    44    50    51    52    53    54    60    61    62    63    70 
  474 12464  3960  1288   615    27 18915  7201  2504   582     6  5072   103   215    65 
   71    72    73    74    75    80    81    82    83    90    91    92    93    94    95 
 7420  6359  1254  3505  1016   122  2323  4443  5610   198 10699  1491  4641   459    32 
   96 
  454 

> ##########################
> #Data file for analysis
> ##########################
> 
> 
> table(our$cntry)

AT BE CH DE DK ES FI FR IE IT NL NO PT SE UK 
26 26 26 26 26 26 26 25 26 26 26 26 24 26 26 

> table(data$cntry)

   AT    BE    CH    DE    DK    ES    FI    FR    GB    IE    IT    NL    NO    PT    SE 
 8713 12577 12335 20490 10836 13543 14275 12981 15667 15490  3696 13505 11703 13718 12839 

> our$cntry[our$cntry=="UK"] <- "GB"

> data_sub <- merge(data, our, by=c("isco2d","cntry"), all=TRUE)

> data_sub %>%
+   dplyr::group_by(cntry,essround,isco2d) %>%
+   dplyr::summarise(our=mean(our,na.rm=T)) -> df

> ##########################
> #Save data
> ##########################
> 
> #Combine ESS with benefit concentration indicator
> save(data_sub,file="DataFile_08_our.Rda")

> ##########################

> ################
> #PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
> #
> #Observational Data
> #Part VIII: Social Spending and Top Tax
> #
> #Verena Fetscher
> #July 2022
> ####################
> 
> rm(list=ls())

> ##########################
> #Load Data
> ##########################
> 
> # Social expenditure
> # In percentage of total government expenditure
> # Source:https://stats.oecd.org/Index.aspx?DataSetCode=SOCX_DET
> socspend<-read.csv("SocialSpending_SOCX_AGG_22102021161051842.csv", header = TRUE, sep = ",", quote = "\"",
+                      dec = ".")

> names(socspend) <- c("SOURCE","Source","BRANCH",
+                      "Branch","TYPEXP","Type.of.Expenditure",
+                      "TYPROG","Type.of.Programme","UNIT",
+                      "Measure","COUNTRY","Country",
+                      "YEAR" ,"Year","Unit.Code",
+                      "Unit","PowerCode.Code","PowerCode",
+                      "Reference.Period.Code", "Reference.Period","Value",
+                      "Flag.Codes","Flags" )

> # top statutory tax rate
> # Source: https://stats.oecd.org/index.aspx?DataSetCode=TABLE_I7
> toptax<-read.csv("TopTax_TABLE_I7_22102021162649482.csv", header = TRUE, sep = ",", quote = "\"",
+                    dec = ".")

> names(toptax) <- c("COU","Country","TAX",
+                    "Income.Tax","YEA","Year",
+                    "Unit.Code","Unit","PowerCode.Code",
+                    "PowerCode","Reference.Period.Code","Reference.Period",
+                    "Value","Flag.Codes","Flags")

> # fiscal redistribution by Mahler and Jesuit (2006)
> # https://www.lisdatacenter.org/resources/other-databases/?highlight=fiscal%20redistribution
> fiscred<-read.csv("fiscal-redistribution-data-2.csv", header = TRUE, sep = ";", quote = "\"",
+                  dec = ",")

> names(fiscred) <- c("Table.A1..Aspects.of.fiscal.redistribution","X","X.1",
+                     "X.2","X.3","X.4","X.5","X.6","X.7","X.8","X.9","X.10" )

> # clean
> fiscred<-fiscred[-c(1:2,4),]

> # First row as colnames
> colnames(fiscred)<-NULL

> colnames(fiscred)<-as.character(t(fiscred[1,]))

> fiscred<-fiscred[-c(1),-(c(3:7,10:25))]

> colnames(fiscred)<- c("country","year","red_taxes","red_transfers")

> fiscred$red_taxes<-gsub(",", ".", fiscred$red_taxes, fixed = TRUE)

> fiscred$red_taxes <- suppressWarnings(sapply(fiscred$red_taxes, as.numeric))

> fiscred$red_transfers<-gsub(",", ".", fiscred$red_transfers, fixed = TRUE)

> fiscred$red_transfers <- suppressWarnings(sapply(fiscred$red_transfers, as.numeric))

> fiscred$year<-as.numeric(fiscred$year)

> unique(fiscred$country)
 [1] "Australia"   "Austria"     "Belgium"     "Canada"      "Denmark"     "Finland"    
 [7] "Germany"     "Greece"      "Iceland"     "Ireland"     "Italy"       "Japan"      
[13] "Luxembourg"  "Netherlands" "Norway"      "Spain"       "Sweden"      "Switzerland"
[19] "UK"          "USA"        

> fiscred$country[fiscred$country=="UK"]<-"United Kingdom"

> unique(fiscred$country)
 [1] "Australia"      "Austria"        "Belgium"        "Canada"         "Denmark"       
 [6] "Finland"        "Germany"        "Greece"         "Iceland"        "Ireland"       
[11] "Italy"          "Japan"          "Luxembourg"     "Netherlands"    "Norway"        
[16] "Spain"          "Sweden"         "Switzerland"    "United Kingdom" "USA"           

> # data frame
> load("DataFile_08_our.Rda")

> data_sub$country<-as.character(data_sub$country)

> unique(data_sub$country)
 [1] "Austria"        "Belgium"        "Switzerland"    "Germany"        "Denmark"       
 [6] "Spain"          "Finland"        "France"         "United Kingdom" "Ireland"       
[11] "Netherlands"    "Norway"         "Portugal"       "Sweden"         "Italy"         

> (unique(data_sub$country) %in% unique(fiscred$country))
 [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE

> (unique(data_sub$year) %in% unique(fiscred$year))
[1]  TRUE FALSE  TRUE  TRUE  TRUE FALSE FALSE

> ##########################
> # Filter data
> ##########################
> socspend%>%
+   filter(Source=="Public"&
+            Branch=="Total"&
+            Type.of.Expenditure=="Total"&
+            Type.of.Programme=="Total"&
+            Measure=="In percentage of Total General Government Expenditure")%>%
+   select(Country,Year,Value) -> socspend

> names(socspend) <- c("country","year","social_spending")

> toptax %>%
+   select(Country,Year,Value) -> toptax

> names(toptax) <- c("country","year","toptax")

> ##########################
> # Merge data
> ##########################
> data_sub <- merge(data_sub, socspend, by.x = c("country","year"), 
+                by.y = c("country","year"), all.x = TRUE, all.y = FALSE)

> data_sub <- merge(data_sub, toptax, by.x = c("country","year"), 
+                   by.y = c("country","year"), all.x = TRUE, all.y = FALSE)

> data_sub <- merge(data_sub, fiscred, by.x = c("country","year"), 
+                   by.y = c("country","year"), all.x = TRUE, all.y = FALSE)

> ##########################
> #Save data
> ##########################
> 
> #Combine ESS with benefit concentration indicator
> save(data_sub,file="DataFile_09_spending_tax.Rda")

> ##########################

> ################
> #PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
> #
> #Observational Analysis ESS
> #Part IX: Missing Data
> #
> #Verena Fetscher
> #July 2022
> ####################
> 
> rm(list=ls())

> ##########################
> #Load data
> ##########################
> 
> load("DataFile_09_spending_tax.Rda")

> ##########################
> #Missing Data
> ##########################
> data_sub %>%
+   group_by(cntry,year) %>%
+   summarise(income=mean(income.dist.th,na.rm=T))%>%
+   filter(is.na(income)) %>%
+   print(n=10)
# A tibble: 4 × 3
# Groups:   cntry [3]
  cntry  year income
  <chr> <dbl>  <dbl>
1 FR     2002    NaN
2 IE     2002    NaN
3 IE     2006    NaN
4 PT     2010    NaN

> #Remove data with missing income year
> data_sub<-data_sub[!((data_sub$country=="France"&
+                         data_sub$year==2002)|
+                        (data_sub$country=="Ireland"&
+                           data_sub$year==2002)|
+                        (data_sub$country=="Ireland"&
+                           data_sub$year==2006)|
+                        (data_sub$country=="Portugal"&
+                           data_sub$year==2010)),]

> data_sub %>%
+   group_by(cntry,year) %>%
+   summarise(income=mean(income.dist.th,na.rm=T))%>%
+   print(n=10)
# A tibble: 94 × 3
# Groups:   cntry [15]
   cntry  year   income
   <chr> <dbl>    <dbl>
 1 AT     2002 2.07e-15
 2 AT     2004 3.18e-15
 3 AT     2006 1.20e-15
 4 AT     2014 4.28e-17
 5 BE     2002 1.39e-15
 6 BE     2004 1.86e-15
 7 BE     2006 2.43e-15
 8 BE     2008 1.76e-15
 9 BE     2010 5.13e-16
10 BE     2012 2.71e-15
# … with 84 more rows
# ℹ Use `print(n = ...)` to see more rows

> #Check for missing data in all columns
> sapply(data_sub, function(x) sum(is.na(x)))
           country               year             isco2d              cntry           essround 
                 0                  0              22845                  0                  0 
           hinctnt           hinctnta            dweight            pspwght            pweight 
            120866              98554                  0                  0                  0 
            iscoco             isco08            marital           maritala           maritalb 
             66650             135483             131988             132384             110065 
           chldhhe            gincdif            pplstrd               gndr             uempla 
             65957               3287             133346                 65                  0 
            eduyrs               agea            hincfel             health            lrscale 
              1778                553               3526                156              17099 
           stflife               rtrd              hhmmb             income         income.PPP 
               591                  0                175              34551              34551 
       income_dist    benefitsFamType        benefitsAvg    benefitsAvgYear        immigration 
             34551             108257                  0                  0                  0 
          mobility      mobility_year         occupation               risk       unemployment 
                 0              92716              17264              40421                  0 
            single          married67          cntryName          gini.disp redistribution_num 
                 0                  0                  0                  0               3287 
    redistribution           identity      income.PPP.th     income.dist.th             gender 
              3287             133346              34551              34551                 65 
             uempl             benLev           benLevAW         isco08_num                our 
                 0                  0                  0             135483              32027 
   social_spending             toptax          red_taxes      red_transfers 
                 0                  0             145955             145955 

> data_sub %>%
+   group_by(cntry,year) %>%
+   summarise(risk=mean(our,na.rm=T))%>%
+   print(n=100)
# A tibble: 94 × 3
# Groups:   cntry [15]
   cntry  year   risk
   <chr> <dbl>  <dbl>
 1 AT     2002 0.0588
 2 AT     2004 0.0623
 3 AT     2006 0.0620
 4 AT     2014 0.0648
 5 BE     2002 0.107 
 6 BE     2004 0.104 
 7 BE     2006 0.102 
 8 BE     2008 0.101 
 9 BE     2010 0.102 
10 BE     2012 0.0964
11 BE     2014 0.0983
12 CH     2002 0.0165
13 CH     2004 0.0177
14 CH     2006 0.0185
15 CH     2008 0.0169
16 CH     2010 0.0171
17 CH     2012 0.0159
18 CH     2014 0.0160
19 DE     2002 0.0981
20 DE     2004 0.0964
21 DE     2006 0.0974
22 DE     2008 0.0949
23 DE     2010 0.0950
24 DE     2012 0.0944
25 DE     2014 0.0876
26 DK     2002 0.0501
27 DK     2004 0.0479
28 DK     2006 0.0437
29 DK     2008 0.0442
30 DK     2010 0.0471
31 DK     2012 0.0454
32 DK     2014 0.0427
33 ES     2002 0.159 
34 ES     2004 0.142 
35 ES     2006 0.151 
36 ES     2008 0.151 
37 ES     2010 0.147 
38 ES     2012 0.142 
39 ES     2014 0.146 
40 FI     2002 0.0665
41 FI     2004 0.0654
42 FI     2006 0.0638
43 FI     2008 0.0621
44 FI     2010 0.0617
45 FI     2012 0.0653
46 FI     2014 0.0653
47 FR     2004 0.0885
48 FR     2006 0.0872
49 FR     2008 0.0872
50 FR     2010 0.0876
51 FR     2012 0.0861
52 FR     2014 0.0886
53 GB     2002 0.0438
54 GB     2004 0.0418
55 GB     2006 0.0425
56 GB     2008 0.0427
57 GB     2010 0.0429
58 GB     2012 0.0420
59 GB     2014 0.0401
60 IE     2004 0.0929
61 IE     2008 0.0948
62 IE     2010 0.0956
63 IE     2012 0.0904
64 IE     2014 0.0964
65 IT     2002 0.0987
66 IT     2004 0.0971
67 IT     2012 0.0908
68 NL     2002 0.0150
69 NL     2004 0.0149
70 NL     2006 0.0153
71 NL     2008 0.0150
72 NL     2010 0.0147
73 NL     2012 0.0139
74 NL     2014 0.0143
75 NO     2002 0.0233
76 NO     2004 0.0248
77 NO     2006 0.0240
78 NO     2008 0.0233
79 NO     2010 0.0238
80 NO     2012 0.0205
81 NO     2014 0.0190
82 PT     2002 0.113 
83 PT     2004 0.109 
84 PT     2006 0.114 
85 PT     2008 0.112 
86 PT     2012 0.102 
87 PT     2014 0.103 
88 SE     2002 0.0350
89 SE     2004 0.0354
90 SE     2006 0.0342
91 SE     2008 0.0332
92 SE     2010 0.0337
93 SE     2012 0.0299
94 SE     2014 0.0286

> data_sub %>%
+   group_by(cntry,year) %>%
+   summarise(risk=mean(our,na.rm=T))%>%
+   print(n=100)
# A tibble: 94 × 3
# Groups:   cntry [15]
   cntry  year   risk
   <chr> <dbl>  <dbl>
 1 AT     2002 0.0588
 2 AT     2004 0.0623
 3 AT     2006 0.0620
 4 AT     2014 0.0648
 5 BE     2002 0.107 
 6 BE     2004 0.104 
 7 BE     2006 0.102 
 8 BE     2008 0.101 
 9 BE     2010 0.102 
10 BE     2012 0.0964
11 BE     2014 0.0983
12 CH     2002 0.0165
13 CH     2004 0.0177
14 CH     2006 0.0185
15 CH     2008 0.0169
16 CH     2010 0.0171
17 CH     2012 0.0159
18 CH     2014 0.0160
19 DE     2002 0.0981
20 DE     2004 0.0964
21 DE     2006 0.0974
22 DE     2008 0.0949
23 DE     2010 0.0950
24 DE     2012 0.0944
25 DE     2014 0.0876
26 DK     2002 0.0501
27 DK     2004 0.0479
28 DK     2006 0.0437
29 DK     2008 0.0442
30 DK     2010 0.0471
31 DK     2012 0.0454
32 DK     2014 0.0427
33 ES     2002 0.159 
34 ES     2004 0.142 
35 ES     2006 0.151 
36 ES     2008 0.151 
37 ES     2010 0.147 
38 ES     2012 0.142 
39 ES     2014 0.146 
40 FI     2002 0.0665
41 FI     2004 0.0654
42 FI     2006 0.0638
43 FI     2008 0.0621
44 FI     2010 0.0617
45 FI     2012 0.0653
46 FI     2014 0.0653
47 FR     2004 0.0885
48 FR     2006 0.0872
49 FR     2008 0.0872
50 FR     2010 0.0876
51 FR     2012 0.0861
52 FR     2014 0.0886
53 GB     2002 0.0438
54 GB     2004 0.0418
55 GB     2006 0.0425
56 GB     2008 0.0427
57 GB     2010 0.0429
58 GB     2012 0.0420
59 GB     2014 0.0401
60 IE     2004 0.0929
61 IE     2008 0.0948
62 IE     2010 0.0956
63 IE     2012 0.0904
64 IE     2014 0.0964
65 IT     2002 0.0987
66 IT     2004 0.0971
67 IT     2012 0.0908
68 NL     2002 0.0150
69 NL     2004 0.0149
70 NL     2006 0.0153
71 NL     2008 0.0150
72 NL     2010 0.0147
73 NL     2012 0.0139
74 NL     2014 0.0143
75 NO     2002 0.0233
76 NO     2004 0.0248
77 NO     2006 0.0240
78 NO     2008 0.0233
79 NO     2010 0.0238
80 NO     2012 0.0205
81 NO     2014 0.0190
82 PT     2002 0.113 
83 PT     2004 0.109 
84 PT     2006 0.114 
85 PT     2008 0.112 
86 PT     2012 0.102 
87 PT     2014 0.103 
88 SE     2002 0.0350
89 SE     2004 0.0354
90 SE     2006 0.0342
91 SE     2008 0.0332
92 SE     2010 0.0337
93 SE     2012 0.0299
94 SE     2014 0.0286

> ##########################
> #Handling Missing Data
> ##########################
> 
> #1) Listwise deletion 
> data_sub %>%
+   drop_na(income.PPP,redistribution,
+           gender,agea,eduyrs,uempl,our) -> data_list

> data_list %>%
+   group_by(cntry,year) %>%
+   summarise(income=mean(income.dist.th,na.rm=T),
+             redistribution=mean(redistribution,na.rm=T),
+             risk=mean(our,na.rm=T),
+             benefits=mean(benefitsAvg,na.rm=T),
+             gender=mean(gender,na.rm=T),
+             age=mean(agea,na.rm=T),
+             education=mean(eduyrs,na.rm=T),
+             unemployment=mean(uempl,na.rm=T),
+             gini=mean(gini.disp,na.rm=T),
+             immigration=mean(immigration,na.rm=T),
+             social_spending=mean(social_spending,na.rm=T),
+             toptax=mean(toptax,na.rm=T),
+             red_taxes=mean(red_taxes,na.rm=T),
+             red_transfers=mean(red_transfers,na.rm=T))
# A tibble: 94 × 16
# Groups:   cntry [15]
   cntry  year income redis…¹   risk benef…² gender   age educa…³ unemp…⁴  gini immig…⁵ socia…⁶
   <chr> <dbl>  <dbl>   <dbl>  <dbl>   <dbl>  <dbl> <dbl>   <dbl>   <dbl> <dbl>   <dbl>   <dbl>
 1 AT     2002  1.14     3.75 0.0576   0.385  0.531  47.0    12.7  0.0229  26.9    13.8    51.0
 2 AT     2004  0.589    3.79 0.0611   0.385  0.524  46.7    12.2  0.0301  27      14.1    49.0
 3 AT     2006  1.09     3.90 0.0625   0.385  0.519  47.1    12.6  0.0214  27.6    14.5    50.9
 4 AT     2014 -0.797    4.13 0.0644   0.385  0.546  50.6    12.3  0.0339  27.7    16.7    52.9
 5 BE     2002  0.449    3.75 0.106    0.640  0.445  46.0    12.4  0.0239  26.6    10.8    49.1
 6 BE     2004  0.533    3.67 0.105    0.640  0.487  46.9    12.5  0.0432  26.5    11.4    51.6
 7 BE     2006  0.861    3.77 0.100    0.640  0.507  48.7    12.4  0.0304  26      12.1    51.7
 8 BE     2008  1.04     3.80 0.0999   0.640  0.478  48.2    13.0  0.0309  25.7    13.0    52.1
 9 BE     2010  0.622    3.81 0.101    0.640  0.509  48.7    12.9  0.0335  25.6    13.9    52.8
10 BE     2012  0.645    3.80 0.0949   0.640  0.514  48.6    13.2  0.0350  25.5    15.0    51.0
# … with 84 more rows, 3 more variables: toptax <dbl>, red_taxes <dbl>, red_transfers <dbl>,
#   and abbreviated variable names ¹​redistribution, ²​benefits, ³​education, ⁴​unemployment,
#   ⁵​immigration, ⁶​social_spending
# ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names

> data_list%>%
+   dplyr::group_by(cntry,year,isco2d) %>%
+   dplyr::summarise(n = n(),mean = mean(our,na.rm=T))%>%
+   print(n=100)
# A tibble: 2,350 × 5
# Groups:   cntry, year [94]
    cntry  year isco2d     n    mean
    <chr> <dbl> <chr>  <int>   <dbl>
  1 AT     2002 12        60 0.0499 
  2 AT     2002 13        38 0.0306 
  3 AT     2002 21         9 0.0388 
  4 AT     2002 22         9 0.00502
  5 AT     2002 23        33 0.0144 
  6 AT     2002 24        51 0.0395 
  7 AT     2002 31        68 0.0375 
  8 AT     2002 32        59 0.0315 
  9 AT     2002 33        82 0.0218 
 10 AT     2002 34       116 0.0493 
 11 AT     2002 41       208 0.0404 
 12 AT     2002 42        64 0.0410 
 13 AT     2002 51       110 0.0740 
 14 AT     2002 52        85 0.0856 
 15 AT     2002 61        30 0.0246 
 16 AT     2002 71        31 0.104  
 17 AT     2002 72        44 0.0712 
 18 AT     2002 73         6 0.0400 
 19 AT     2002 74        31 0.111  
 20 AT     2002 81         4 0.0893 
 21 AT     2002 82        15 0.111  
 22 AT     2002 83        29 0.0721 
 23 AT     2002 91        51 0.137  
 24 AT     2002 92         2 0.0680 
 25 AT     2002 93        30 0.180  
 26 AT     2004 11         3 0.0187 
 27 AT     2004 12        23 0.0499 
 28 AT     2004 13         7 0.0306 
 29 AT     2004 21        17 0.0388 
 30 AT     2004 22         5 0.00502
 31 AT     2004 23       101 0.0144 
 32 AT     2004 24        29 0.0395 
 33 AT     2004 31        58 0.0375 
 34 AT     2004 32        52 0.0315 
 35 AT     2004 33         4 0.0218 
 36 AT     2004 34        23 0.0493 
 37 AT     2004 41       212 0.0404 
 38 AT     2004 42        86 0.0410 
 39 AT     2004 51        94 0.0740 
 40 AT     2004 52        92 0.0856 
 41 AT     2004 61        22 0.0246 
 42 AT     2004 71        27 0.104  
 43 AT     2004 72        29 0.0712 
 44 AT     2004 73         9 0.0400 
 45 AT     2004 74        24 0.111  
 46 AT     2004 81         2 0.0893 
 47 AT     2004 82        13 0.111  
 48 AT     2004 83        25 0.0721 
 49 AT     2004 91        57 0.137  
 50 AT     2004 92         2 0.0680 
 51 AT     2004 93        47 0.180  
 52 AT     2006 11         1 0.0187 
 53 AT     2006 12        41 0.0499 
 54 AT     2006 13        38 0.0306 
 55 AT     2006 21        18 0.0388 
 56 AT     2006 22        17 0.00502
 57 AT     2006 23        89 0.0144 
 58 AT     2006 24        44 0.0395 
 59 AT     2006 31        56 0.0375 
 60 AT     2006 32        40 0.0315 
 61 AT     2006 33         8 0.0218 
 62 AT     2006 34       128 0.0493 
 63 AT     2006 41       166 0.0404 
 64 AT     2006 42        44 0.0410 
 65 AT     2006 51       183 0.0740 
 66 AT     2006 52       106 0.0856 
 67 AT     2006 61        34 0.0246 
 68 AT     2006 71        52 0.104  
 69 AT     2006 72        53 0.0712 
 70 AT     2006 73         4 0.0400 
 71 AT     2006 74        30 0.111  
 72 AT     2006 81         4 0.0893 
 73 AT     2006 82        19 0.111  
 74 AT     2006 83        26 0.0721 
 75 AT     2006 91        71 0.137  
 76 AT     2006 92         3 0.0680 
 77 AT     2006 93        33 0.180  
 78 AT     2014 11        16 0.0187 
 79 AT     2014 12        13 0.0499 
 80 AT     2014 13        22 0.0306 
 81 AT     2014 21        16 0.0388 
 82 AT     2014 22        11 0.00502
 83 AT     2014 23        71 0.0144 
 84 AT     2014 31        27 0.0375 
 85 AT     2014 32        37 0.0315 
 86 AT     2014 33        50 0.0218 
 87 AT     2014 34        21 0.0493 
 88 AT     2014 41        78 0.0404 
 89 AT     2014 42        39 0.0410 
 90 AT     2014 51       218 0.0740 
 91 AT     2014 61        46 0.0246 
 92 AT     2014 71        46 0.104  
 93 AT     2014 72        48 0.0712 
 94 AT     2014 73         8 0.0400 
 95 AT     2014 74        20 0.111  
 96 AT     2014 81        24 0.0893 
 97 AT     2014 82         8 0.111  
 98 AT     2014 83        51 0.0721 
 99 AT     2014 91        51 0.137  
100 AT     2014 92         7 0.0680 
# … with 2,250 more rows
# ℹ Use `print(n = ...)` to see more rows

> data_list %>%
+   mutate(across(c(isco2d,hincfel,health,lrscale,stflife,rtrd), 
+                 ~as.numeric(.))) -> data_list

> ##########################
> 
> 
> 
> #2) Multiple Imputation
> #Subsetting data with additional variables to improve income prediction in imputation
> #hhmmb: Number of people living regularly as member of household (dependent children)
> #hincfel: Feeling about household's income nowadays (satisfaction with own income)
> #health: Subjective general health (subjective health)
> #lrscale: Placement on left right scale (political ideology)
> #stflife: How satisfied with life as a whole (life satisfaction)
> #rtrd: retired
> 
> 
> #Subsetting data
> #Remove modified income data (generate anew after imputation)
> data_sub%>%
+   select(country,year,income.PPP,income.dist.th,
+          redistribution,our,isco2d,gender,agea,
+          eduyrs,uempl,single,married67,
+          benefitsAvg,benLev,benefitsAvgYear,
+          hhmmb,hincfel,health,lrscale,
+          stflife,rtrd,immigration,gini.disp,
+          social_spending,toptax,red_taxes,red_transfers) -> data_sub

> x<-sub('.*sub.', '', names(data_sub))

> names(data_sub)<-x

> rm(x)

> #Change variable class from factor to numeric
> data_sub %>%
+   mutate(across(c(isco2d,hincfel,health,lrscale,stflife,rtrd), 
+                 ~as.numeric(.))) -> data_sub

> #Remove empty factor values for country
> data_sub$country <- factor(data_sub$country)

> table(data_sub$country)

       Austria        Belgium        Denmark        Finland         France        Germany 
          8713          12577          10836          14275          11478          20490 
       Ireland          Italy    Netherlands         Norway       Portugal          Spain 
         11644           3696          13505          11703          11568          13543 
        Sweden    Switzerland United Kingdom 
         12839          12335          15667 

> names(data_sub) 
 [1] "country"         "year"            "income.PPP"      "income.dist.th"  "redistribution" 
 [6] "our"             "isco2d"          "gender"          "agea"            "eduyrs"         
[11] "uempl"           "single"          "married67"       "benefitsAvg"     "benLev"         
[16] "benefitsAvgYear" "hhmmb"           "hincfel"         "health"          "lrscale"        
[21] "stflife"         "rtrd"            "immigration"     "gini.disp"       "social_spending"
[26] "toptax"          "red_taxes"       "red_transfers"  

> str(data_sub)
'data.frame':	184869 obs. of  28 variables:
 $ country        : Factor w/ 15 levels "Austria","Belgium",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ year           : num  2002 2002 2002 2002 2002 ...
 $ income.PPP     : num  85039 NA 23811 NA NA ...
 $ income.dist.th : num  56.44 NA -4.79 NA NA ...
 $ redistribution : num  1 5 4 4 1 2 5 4 4 4 ...
 $ our            : num  NA NA NA 0.0388 0.0388 ...
 $ isco2d         : num  10 10 10 21 21 31 91 31 51 NA ...
 $ gender         : num  0 0 0 0 0 0 1 0 0 1 ...
 $ agea           : num  60 27 61 27 46 45 67 63 36 90 ...
 $ eduyrs         : num  13 12 18 18 12 12 8 15 14 8 ...
 $ uempl          : num  0 0 0 0 0 0 0 0 0 0 ...
 $ single         : num  0 1 0 1 0 0 0 0 0 0 ...
 $ married67      : num  1 0 0 0 0 0 0 0 0 0 ...
 $ benefitsAvg    : num  0.385 0.385 0.385 0.385 0.385 ...
 $ benLev         : num  0.464 0.464 0.464 0.464 0.464 ...
 $ benefitsAvgYear: num  0.373 0.373 0.373 0.373 0.373 ...
 $ hhmmb          : num  2 1 1 2 4 5 1 2 2 2 ...
 $ hincfel        : num  1 1 2 1 1 2 2 2 1 2 ...
 $ health         : num  2 1 2 2 1 2 1 3 2 3 ...
 $ lrscale        : num  8 6 6 7 1 4 6 4 6 7 ...
 $ stflife        : num  11 8 8 10 11 9 8 7 10 11 ...
 $ rtrd           : num  2 1 1 1 1 1 2 2 1 2 ...
 $ immigration    : num  13.8 13.8 13.8 13.8 13.8 ...
 $ gini.disp      : num  26.9 26.9 26.9 26.9 26.9 26.9 26.9 26.9 26.9 26.9 ...
 $ social_spending: num  51 51 51 51 51 ...
 $ toptax         : num  43.7 43.7 43.7 43.7 43.7 ...
 $ red_taxes      : num  NA NA NA NA NA NA NA NA NA NA ...
 $ red_transfers  : num  NA NA NA NA NA NA NA NA NA NA ...

> ##########################
> 
> 
> #Amelia for multiple imputations
> #https://gking.harvard.edu/amelia
> 
> #Map missing data
> #missmap(data_sub)
> 
> #Table with missing data
> pMiss <- function(x){sum(is.na(x))/length(x)*100}

> df01<-apply(data_sub,2,pMiss)

> df01
        country            year      income.PPP  income.dist.th  redistribution 
     0.00000000      0.00000000     18.68945037     18.68945037      1.77801578 
            our          isco2d          gender            agea          eduyrs 
    17.32415927     12.35739902      0.03516003      0.29913074      0.96176211 
          uempl          single       married67     benefitsAvg          benLev 
     0.00000000      0.00000000      0.00000000      0.00000000      0.00000000 
benefitsAvgYear           hhmmb         hincfel          health         lrscale 
     0.00000000      0.09466163      1.90729652      0.08438408      9.24925217 
        stflife            rtrd     immigration       gini.disp social_spending 
     0.31968583      0.00000000      0.00000000      0.00000000      0.00000000 
         toptax       red_taxes   red_transfers 
     0.00000000     78.95050008     78.95050008 

> #Remove missing age and gender
> data_sub %>%
+   drop_na(gender,agea) -> data_sub

> #Generate 5 data sets with mutliply imputed data
> table(data_sub$isco2d)

   10    11    12    13    20    21    22    23    24    30    31    32    33    34    35 
  427   764  6770  5549    64  4328  3599  8601  5440    26  6044  5056  5102 10852   319 
   40    41    42    43    44    50    51    52    53    54    60    61    62    63    70 
  462 11780  3789  1287   613    27 18096  6678  2502   582     6  4732   103   215    65 
   71    72    73    74    75    80    81    82    83    90    91    92    93    94    95 
 7099  6132  1188  3248  1013   120  2284  4099  5402   194 10178  1434  4470   459    32 
   96 
  454 

> #set occupational unemployment rate between 0 and 1
> bds <- matrix(c(6, 0, 1), nrow = 1, ncol = 3)

> a.out<-amelia(data_sub,m=5,ts="year",cs="country",
+               idvars=c("income.dist.th","gini.disp",
+                        "immigration","social_spending","toptax",
+                        "red_taxes","red_transfers"), 
+               #idvars kept in imputed data fame in order to get correct dimensions and recode according to imputed income data afterwards
+               ords=c("uempl","redistribution"),
+               bounds=bds)
-- Imputation 1 --

  1  2  3  4  5  6

-- Imputation 2 --

  1  2  3  4  5  6

-- Imputation 3 --

  1  2  3  4  5  6

-- Imputation 4 --

  1  2  3  4  5  6

-- Imputation 5 --

  1  2  3  4  5  6


> ##########################
> 
> summary(a.out$imputations$imp1$our)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
0.00000 0.02478 0.05426 0.06979 0.10386 0.68925 

> ##########################
> #Data inspection
> ##########################
> table(is.na(a.out$imputations$imp1))

  FALSE    TRUE 
4835020  325156 

> summary(a.out)

Amelia output with 5 imputed datasets.
Return code:  1 
Message:  Normal EM convergence. 

Chain Lengths:
--------------
Imputation 1:  6
Imputation 2:  6
Imputation 3:  6
Imputation 4:  6
Imputation 5:  6

Rows after Listwise Deletion:  26396 
Rows after Imputation:  31016 
Patterns of missingness in the data:  299 

Fraction Missing for original variables: 
-----------------------------------------

                Fraction Missing
country             0.0000000000
year                0.0000000000
income.PPP          0.1855642133
income.dist.th      0.1855642133
redistribution      0.0175211078
our                 0.1724003212
isco2d              0.1226748855
gender              0.0000000000
agea                0.0000000000
eduyrs              0.0089857400
uempl               0.0000000000
single              0.0000000000
married67           0.0000000000
benefitsAvg         0.0000000000
benLev              0.0000000000
benefitsAvgYear     0.0000000000
hhmmb               0.0005697480
hincfel             0.0186280468
health              0.0007488117
lrscale             0.0919464762
stflife             0.0030820654
rtrd                0.0000000000
immigration         0.0000000000
gini.disp           0.0000000000
social_spending     0.0000000000
toptax              0.0000000000
red_taxes           0.7893940052
red_transfers       0.7893940052


> summary(a.out$imputations$imp1$redistribution)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   1.00    3.00    4.00    3.75    5.00    5.00 

> summary(a.out$imputations$imp1$isco2d)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 -44.11   32.00   51.00   49.94   71.79  146.24 

> compare.density(a.out, var = "our")

> compare.density(a.out, var = "income.PPP")

> plot(a.out,which.vars=3)

> #missmap(a.out)
> #overimpute(a.out, var = "income.PPP")
> #disperse(a.out,m=5)
> 
> 
> 
> ##########################
> #Recode data
> ##########################
> 
> #Income in thousands
> a.out$imputations$imp1$income.PPP.th<-a.out$imputations$imp1$income.PPP/1000

> a.out$imputations$imp2$income.PPP.th<-a.out$imputations$imp2$income.PPP/1000

> a.out$imputations$imp3$income.PPP.th<-a.out$imputations$imp3$income.PPP/1000

> a.out$imputations$imp4$income.PPP.th<-a.out$imputations$imp4$income.PPP/1000

> a.out$imputations$imp5$income.PPP.th<-a.out$imputations$imp5$income.PPP/1000

> summary(a.out$imputations$imp1$income.PPP.th)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 -88.88   17.59   30.61   36.71   48.46  413.55 

> summary(a.out$imputations$imp2$income.PPP.th)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 -74.93   17.59   30.61   36.67   48.46  413.55 

> summary(a.out$imputations$imp3$income.PPP.th)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 -69.27   17.59   30.61   36.69   48.54  413.55 

> summary(a.out$imputations$imp4$income.PPP.th)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 -71.72   17.59   30.61   36.68   48.45  413.55 

> summary(a.out$imputations$imp5$income.PPP.th)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 -76.14   17.59   30.61   36.72   48.57  413.55 

> #compare
> summary(data_list$income.PPP.th)
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
  0.7162  18.6769  30.3122  37.4113  47.4718 413.5539 

> ##########################
> 
> 
> typeof(a.out$imputations$imp1$country)
[1] "integer"

> #Generate income distance by country by year
> #Data frame 1
> a.out$imputations$imp1$cntry_num<-as.numeric(a.out$imputations$imp1$country)

> for(i in 1:15){
+   for(j in c(2002,2004,2006,2008,2010,2012,2014)) {
+     a.out$imputations$imp1$income.dist.th[a.out$imputations$imp1$cntry_num==i&
+                                             a.out$imputations$imp1$year==j]<-
+       a.out$imputations$imp1$income.PPP.th[a.out$imputations$imp1$cntry_num==i&
+                                              a.out$imputations$imp1$year==j]-
+       mean(a.out$imputations$imp1$income.PPP.th[a.out$imputations$imp1$cntry_num==i&
+                                                   a.out$imputations$imp1$year==j],
+            na.rm=T)
+   }
+ }

> #check
> summary(a.out$imputations$imp1$income.dist.th[a.out$imputations$imp1$country=="Switzerland"&
+                                                 a.out$imputations$imp1$year==2008])
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-90.469 -15.558  -3.699   0.000  10.828  87.333 

> ##########################
> 
> 
> #Data frame 2
> a.out$imputations$imp2$cntry_num<-as.numeric(a.out$imputations$imp2$country)

> for(i in 1:15){
+   for(j in c(2002,2004,2006,2008,2010,2012,2014)) {
+     a.out$imputations$imp2$income.dist.th[a.out$imputations$imp2$cntry_num==i&
+                                             a.out$imputations$imp2$year==j]<-
+       a.out$imputations$imp2$income.PPP.th[a.out$imputations$imp2$cntry_num==i&
+                                              a.out$imputations$imp2$year==j]-
+       mean(a.out$imputations$imp2$income.PPP.th[a.out$imputations$imp2$cntry_num==i&
+                                                   a.out$imputations$imp2$year==j],
+            na.rm=T)
+   }
+ }

> summary(a.out$imputations$imp2$income.dist.th[a.out$imputations$imp2$country=="Switzerland"&
+                                                 a.out$imputations$imp2$year==2008])
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-77.610 -15.911  -4.053   0.000  10.474 102.567 

> ##########################
> 
> 
> #Data frame 3
> a.out$imputations$imp3$cntry_num<-as.numeric(a.out$imputations$imp3$country)

> for(i in 1:15){
+   for(j in c(2002,2004,2006,2008,2010,2012,2014)) {
+     a.out$imputations$imp3$income.dist.th[a.out$imputations$imp3$cntry_num==i&
+                                             a.out$imputations$imp3$year==j]<-
+       a.out$imputations$imp3$income.PPP.th[a.out$imputations$imp3$cntry_num==i&
+                                              a.out$imputations$imp3$year==j]-
+       mean(a.out$imputations$imp3$income.PPP.th[a.out$imputations$imp3$cntry_num==i&
+                                                   a.out$imputations$imp3$year==j],
+            na.rm=T)
+   }
+ }

> summary(a.out$imputations$imp3$income.dist.th[a.out$imputations$imp3$country=="Switzerland"&
+                                                 a.out$imputations$imp3$year==2008])
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-102.512  -16.044   -4.186    0.000   10.341   86.846 

> ##########################
> 
> 
> #Data frame 4
> a.out$imputations$imp4$cntry_num<-as.numeric(a.out$imputations$imp4$country)

> for(i in 1:15){
+   for(j in c(2002,2004,2006,2008,2010,2012,2014)) {
+     a.out$imputations$imp4$income.dist.th[a.out$imputations$imp4$cntry_num==i&
+                                             a.out$imputations$imp4$year==j]<-
+       a.out$imputations$imp4$income.PPP.th[a.out$imputations$imp4$cntry_num==i&
+                                              a.out$imputations$imp4$year==j]-
+       mean(a.out$imputations$imp4$income.PPP.th[a.out$imputations$imp4$cntry_num==i&
+                                                   a.out$imputations$imp4$year==j],
+            na.rm=T)
+   }
+ }

> summary(a.out$imputations$imp4$income.dist.th[a.out$imputations$imp4$country=="Switzerland"&
+                                                 a.out$imputations$imp4$year==2008])
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-81.008 -15.828  -3.969   0.000  10.558  87.063 

> ##########################
> 
> 
> #Data frame 5
> a.out$imputations$imp5$cntry_num<-as.numeric(a.out$imputations$imp5$country)

> for(i in 1:15){
+   for(j in c(2002,2004,2006,2008,2010,2012,2014)) {
+     a.out$imputations$imp5$income.dist.th[a.out$imputations$imp5$cntry_num==i&
+                                             a.out$imputations$imp5$year==j]<-
+       a.out$imputations$imp5$income.PPP.th[a.out$imputations$imp5$cntry_num==i&
+                                              a.out$imputations$imp5$year==j]-
+       mean(a.out$imputations$imp5$income.PPP.th[a.out$imputations$imp5$cntry_num==i&
+                                                   a.out$imputations$imp5$year==j],
+            na.rm=T)
+   }
+ }

> summary(a.out$imputations$imp5$income.dist.th[a.out$imputations$imp5$country=="Switzerland"&
+                                                 a.out$imputations$imp5$year==2008])
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-104.349  -15.791   -3.933    0.000   10.594   87.099 

> ##########################
> 
> mi.out<-to_zelig_mi(a.out$imputations$imp1,a.out$imputations$imp2,a.out$imputations$imp3,
+                     a.out$imputations$imp4,a.out$imputations$imp5)

> ##########################
> #Save data
> ##########################
> 
> save(data_list,file="DataFile_10_listwise.Rda")

> save(mi.out,file="DataFile_11_imputed.Rda")

> ##########################
